Challenge - 5 Problems
Blockchain Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this simple block hash calculation?
Consider a block with data 'Block1' and previous hash '0000'. The hash function returns the length of the combined string. What is the output of the hash calculation?
Blockchain / Solidity
data = 'Block1' previous_hash = '0000' block_string = data + previous_hash block_hash = len(block_string) print(block_hash)
Attempts:
2 left
💡 Hint
Count the characters in 'Block1' plus '0000'.
✗ Incorrect
The string 'Block1' has 6 characters and '0000' has 4 characters, combined length is 10. But the code concatenates them, so total length is 10.
🧠 Conceptual
intermediate1:30remaining
Which property of a cryptographic hash ensures blockchain security?
Which property of a cryptographic hash function makes it hard to change a block without changing its hash?
Attempts:
2 left
💡 Hint
Think about how hard it is to find two inputs with the same hash.
✗ Incorrect
Collision resistance means it is very hard to find two different inputs producing the same hash, so changing block data changes the hash.
🔧 Debug
advanced2:30remaining
Why does this blockchain chain break?
This code tries to link blocks by storing previous hashes. Why does the chain verification fail?
Blockchain / Solidity
blocks = [
{'data': 'Block1', 'prev_hash': '0000', 'hash': 'abc123'},
{'data': 'Block2', 'prev_hash': 'abc123', 'hash': 'def456'},
{'data': 'Block3', 'prev_hash': 'xyz789', 'hash': 'ghi012'}
]
for i in range(1, len(blocks)):
if blocks[i]['prev_hash'] != blocks[i-1]['hash']:
print(f"Chain broken at block {i+1}")
break
else:
print("Chain is valid")Attempts:
2 left
💡 Hint
Check the prev_hash of block 3 and the hash of block 2.
✗ Incorrect
Block 3's prev_hash is 'xyz789' but block 2's hash is 'def456', so the chain breaks at block 3.
📝 Syntax
advanced2:00remaining
Which code snippet correctly creates a block hash using SHA-256?
Select the code that correctly computes a SHA-256 hash of a block's data and previous hash in Python.
Attempts:
2 left
💡 Hint
Remember to encode the string before hashing and use hexdigest() for readable output.
✗ Incorrect
Option A correctly encodes the string and uses hexdigest() to get the hash as a hex string.
🚀 Application
expert3:00remaining
How many blocks are in the valid chain after this code runs?
Given this blockchain list, how many blocks form a valid chain starting from the first block?
Blockchain / Solidity
blockchain = [
{'data': 'Genesis', 'prev_hash': '0', 'hash': 'a1'},
{'data': 'Block1', 'prev_hash': 'a1', 'hash': 'b2'},
{'data': 'Block2', 'prev_hash': 'b2', 'hash': 'c3'},
{'data': 'Block3', 'prev_hash': 'x9', 'hash': 'd4'},
{'data': 'Block4', 'prev_hash': 'd4', 'hash': 'e5'}
]
valid_count = 1
for i in range(1, len(blockchain)):
if blockchain[i]['prev_hash'] == blockchain[i-1]['hash']:
valid_count += 1
else:
break
print(valid_count)Attempts:
2 left
💡 Hint
Check where the prev_hash does not match the previous block's hash.
✗ Incorrect
The chain breaks at Block3 because its prev_hash 'x9' does not match Block2's hash 'c3', so only 3 blocks are valid.