0
0
Blockchain / Solidityprogramming~20 mins

Why security prevents financial loss in Blockchain / Solidity - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Blockchain Security Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why does blockchain security reduce financial loss?

Imagine a blockchain network where transactions are recorded. Why does strong security in this network help prevent financial loss?

ABecause it makes transactions slower, so hackers get tired and give up.
BBecause it hides all transactions so no one can see where money goes.
CBecause it stops unauthorized changes to transaction records, ensuring funds are safe.
DBecause it allows anyone to change records freely, increasing transparency.
Attempts:
2 left
💡 Hint

Think about what happens if someone can change transaction records without permission.

Predict Output
intermediate
2:00remaining
What is the output of this smart contract balance check?

Given this simplified smart contract code snippet, what will be the output after running it?

Blockchain / Solidity
balances = {'Alice': 100, 'Bob': 50}

# Alice tries to send 30 to Bob
amount = 30
sender = 'Alice'
receiver = 'Bob'

if balances.get(sender, 0) >= amount:
    balances[sender] -= amount
    balances[receiver] += amount
    print(f"Transfer successful: {sender} -> {receiver} : {amount}")
else:
    print("Transfer failed: insufficient funds")
AKeyError: 'Alice'
BTransfer failed: insufficient funds
CTransfer successful: Bob -> Alice : 30
DTransfer successful: Alice -> Bob : 30
Attempts:
2 left
💡 Hint

Check if Alice has enough balance before sending.

🔧 Debug
advanced
2:00remaining
Identify the error causing financial loss in this transaction code

Look at this code that handles a transaction. Which option correctly identifies the error that could cause financial loss?

Blockchain / Solidity
def transfer_funds(balances, sender, receiver, amount):
    if balances[sender] > amount:
        balances[sender] -= amount
        balances[receiver] += amount
        return "Transfer complete"
    else:
        return "Insufficient funds"
AThe condition should be >= instead of > to allow exact balance transfers.
BThe function should add amount to sender instead of subtracting.
CThe balances dictionary keys are missing quotes causing a syntax error.
DThe function returns a string instead of updating balances.
Attempts:
2 left
💡 Hint

Think about what happens if sender tries to send all their money.

📝 Syntax
advanced
2:00remaining
What error does this blockchain transaction code raise?

What error will this code produce when executed?

Blockchain / Solidity
transactions = [{'from': 'Alice', 'to': 'Bob', 'amount': 50}]

for tx in transactions:
    print(f"{tx['from']} sends {tx['amount']} to {tx['to']}")
ASyntaxError due to missing colon after for loop
BKeyError because 'from' is a reserved word
CTypeError because transactions is not iterable
DNo error, prints the transaction details
Attempts:
2 left
💡 Hint

Check the for loop syntax carefully.

🚀 Application
expert
2:00remaining
How many unique transactions are recorded after this code runs?

Consider this code that records transactions in a blockchain ledger. How many unique transactions will the ledger contain after execution?

Blockchain / Solidity
ledger = set()

transactions = [
    ('Alice', 'Bob', 20),
    ('Bob', 'Charlie', 15),
    ('Alice', 'Bob', 20),
    ('Charlie', 'Alice', 5)
]

for tx in transactions:
    ledger.add(tx)

print(len(ledger))
A4
B3
C2
D1
Attempts:
2 left
💡 Hint

Sets do not allow duplicate entries. Count unique tuples.