0
0
Blockchain / Solidityprogramming~10 mins

Transaction confirmation handling in Blockchain / Solidity - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to check if a transaction is confirmed.

Blockchain / Solidity
if transaction.status == [1]:
    print("Transaction confirmed")
Drag options to blanks, or click blank then click option'
A"confirmed"
B"pending"
C"failed"
D"unknown"
Attempts:
3 left
💡 Hint
Common Mistakes
Using "pending" instead of "confirmed".
Checking for "failed" status.
2fill in blank
medium

Complete the code to wait for 3 confirmations before proceeding.

Blockchain / Solidity
while transaction.confirmations < [1]:
    wait_for_new_block()
Drag options to blanks, or click blank then click option'
A0
B1
C6
D3
Attempts:
3 left
💡 Hint
Common Mistakes
Using 1 confirmation which might be unsafe.
Using 0 which means no wait.
3fill in blank
hard

Fix the error in the code to correctly check transaction finality.

Blockchain / Solidity
if transaction.confirmations [1] 3:
    print("Transaction is final")
Drag options to blanks, or click blank then click option'
A>=
B==
C<
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' which checks for fewer confirmations.
Using '==' which is too strict.
4fill in blank
hard

Fill both blanks to create a dictionary of transaction IDs with their confirmation counts greater than 2.

Blockchain / Solidity
confirmed_txs = {tx.id: tx[1] for tx in transactions if tx.confirmations [2] 2}
Drag options to blanks, or click blank then click option'
A.confirmations
B>
C>=
D.status
Attempts:
3 left
💡 Hint
Common Mistakes
Using '.status' instead of '.confirmations'.
Using '>=' instead of '>'.
5fill in blank
hard

Fill all three blanks to filter transactions with status 'confirmed' and confirmations at least 3, then map their IDs to confirmation counts.

Blockchain / Solidity
final_txs = {tx[1]: tx[2] for tx in transactions if tx.status == [3] and tx.confirmations >= 3}
Drag options to blanks, or click blank then click option'
A.id
B.confirmations
C"confirmed"
D"pending"
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'pending' instead of 'confirmed' for status.
Mixing up keys and values in the dictionary.