0
0
Blockchain / Solidityprogramming~10 mins

Why standards enable interoperability in Blockchain / Solidity - Test Your Understanding

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

Complete the code to define a standard message format for blockchain transactions.

Blockchain / Solidity
transaction = {"sender": "Alice", "receiver": "Bob", "amount": 10, "currency": [1]
Drag options to blanks, or click blank then click option'
Atransaction
B10
CTrue
D"BTC"
Attempts:
3 left
💡 Hint
Common Mistakes
Using a number instead of a string for currency
Using a boolean value
2fill in blank
medium

Complete the code to check if a transaction follows the standard by verifying the presence of the 'sender' key.

Blockchain / Solidity
if [1] in transaction:
Drag options to blanks, or click blank then click option'
A"sender"
B"receiver"
C"amount"
D"currency"
Attempts:
3 left
💡 Hint
Common Mistakes
Checking for 'receiver' instead of 'sender'
Checking for 'amount'
3fill in blank
hard

Fix the error in the code that validates the transaction amount is positive.

Blockchain / Solidity
if transaction["amount"] [1] 0:
Drag options to blanks, or click blank then click option'
A<
B==
C>
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<=' instead of '>'
Using '==' which only checks for zero
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps transaction IDs to their amounts only if the amount is greater than 5.

Blockchain / Solidity
filtered_transactions = {tx_id: transaction[[1]] for tx_id, transaction in transactions.items() if transaction[[2]] > 5}
Drag options to blanks, or click blank then click option'
A"amount"
B"sender"
D"currency"
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'sender' or 'currency' instead of 'amount'
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps uppercase sender names to their transaction amounts if the currency is 'ETH'.

Blockchain / Solidity
eth_transactions = { [1]: [2] for tx_id, transaction in transactions.items() if transaction[[3]] == "ETH" }
Drag options to blanks, or click blank then click option'
Atransaction["sender"].upper()
Btransaction["amount"]
C"currency"
Dtx_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using tx_id as key instead of sender
Filtering by amount instead of currency