Transaction confirmation handling
📖 Scenario: You are building a simple blockchain wallet app. When you send a transaction, you want to check how many confirmations it has received on the blockchain to know if it is secure.
🎯 Goal: Create a program that stores a transaction with its current confirmation count, sets a confirmation threshold, checks if the transaction is confirmed enough, and then prints a message about the confirmation status.
📋 What You'll Learn
Create a dictionary called
transaction with keys 'id' and 'confirmations' and exact values 'tx123' and 2Create a variable called
confirmation_threshold and set it to 3Create a boolean variable called
is_confirmed that is True if transaction['confirmations'] is greater than or equal to confirmation_threshold, otherwise FalsePrint
Transaction tx123 confirmed if is_confirmed is True, otherwise print Transaction tx123 pending💡 Why This Matters
🌍 Real World
Blockchain wallets and explorers show transaction confirmation status to users so they know when their transactions are secure.
💼 Career
Understanding how to handle transaction confirmations is important for blockchain developers building wallets, exchanges, or monitoring tools.
Progress0 / 4 steps