0
0
Blockchain / Solidityprogramming~20 mins

Why handling value is core to blockchain - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Blockchain Value Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why is value handling essential in blockchain?

Which of the following best explains why handling value is core to blockchain technology?

ABecause blockchain speeds up internet connections by handling data packets efficiently.
BBecause blockchain enables secure and transparent transfer of digital assets or money without a middleman.
CBecause blockchain is mainly used to store large files securely.
DBecause blockchain is designed to create complex graphics for video games.
Attempts:
2 left
💡 Hint

Think about what blockchain is mostly used for in real life.

Predict Output
intermediate
2:00remaining
What is the output of this simple blockchain value transfer simulation?

Consider this Python code simulating a simple blockchain transaction ledger. What will be printed?

Blockchain / Solidity
ledger = []

# Add initial balance
ledger.append({'address': 'Alice', 'balance': 100})
ledger.append({'address': 'Bob', 'balance': 50})

# Alice sends 30 to Bob
for entry in ledger:
    if entry['address'] == 'Alice':
        entry['balance'] -= 30
    elif entry['address'] == 'Bob':
        entry['balance'] += 30

print(ledger)
ASyntaxError
B[{'address': 'Alice', 'balance': 100}, {'address': 'Bob', 'balance': 50}]
C[{'address': 'Alice', 'balance': 70}, {'address': 'Bob', 'balance': 80}]
D[{'address': 'Alice', 'balance': 130}, {'address': 'Bob', 'balance': 20}]
Attempts:
2 left
💡 Hint

Think about how balances change after a transfer.

🔧 Debug
advanced
2:00remaining
Identify the error in this blockchain value update code

What error will this code produce when trying to update balances in a blockchain ledger?

Blockchain / Solidity
ledger = [{'address': 'Alice', 'balance': 100}, {'address': 'Bob', 'balance': 50}]

for entry in ledger:
    if entry['address'] == 'Alice':
        entry['balance'] = entry['balance'] - 30
    elif entry['address'] == 'Bob':
        entry['balance'] += '30'

print(ledger)
AKeyError: 'balance'
BSyntaxError: invalid syntax
CNo error, output: [{'address': 'Alice', 'balance': 70}, {'address': 'Bob', 'balance': 80}]
DTypeError: unsupported operand type(s) for +=: 'int' and 'str'
Attempts:
2 left
💡 Hint

Look carefully at the types used in the addition operation.

📝 Syntax
advanced
2:00remaining
Which option correctly defines a blockchain transaction function?

Which of these Python function definitions correctly handles a transaction by deducting from sender and adding to receiver?

A
def transfer(sender, receiver, amount):
    sender['balance'] = sender['balance'] - amount
    receiver['balance'] = receiver['balance'] + amount
    return sender, receiver
B
def transfer(sender, receiver, amount):
    sender['balance'] -= amount
    receiver['balance'] += amount
C
def transfer(sender, receiver, amount):
    sender.balance -= amount
    receiver.balance += amount
D
def transfer(sender, receiver, amount):
    sender['balance'] = sender['balance'] + amount
    receiver['balance'] = receiver['balance'] - amount
Attempts:
2 left
💡 Hint

Check for correct syntax and logic for transferring value.

🚀 Application
expert
2:00remaining
How many transactions are recorded after this blockchain simulation?

Given this code simulating a blockchain ledger with transactions, how many transactions are recorded in the ledger after running?

Blockchain / Solidity
ledger = []

# Genesis block
ledger.append({'block': 0, 'transactions': []})

# Add transactions
ledger[0]['transactions'].append({'from': 'Alice', 'to': 'Bob', 'amount': 50})
ledger[0]['transactions'].append({'from': 'Bob', 'to': 'Charlie', 'amount': 20})

# Add new block
ledger.append({'block': 1, 'transactions': [{'from': 'Charlie', 'to': 'Alice', 'amount': 10}]})
A3
B1
C2
D4
Attempts:
2 left
💡 Hint

Count all transactions inside all blocks.