Challenge - 5 Problems
Ethereum Programmable Money Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this Solidity smart contract function?
Consider this simple Solidity function that returns the balance of an address in a token contract. What will be the output when calling
getBalance() if the balance mapping has balances[msg.sender] = 100?Blockchain / Solidity
pragma solidity ^0.8.0; contract Token { mapping(address => uint) balances; constructor() { balances[msg.sender] = 100; } function getBalance() public view returns (uint) { return balances[msg.sender]; } }
Attempts:
2 left
💡 Hint
Think about what the constructor does when the contract is deployed.
✗ Incorrect
The constructor sets the balance of the deployer (msg.sender) to 100. Calling getBalance() from the deployer's address returns 100.
🧠 Conceptual
intermediate1:30remaining
Why does Ethereum enable programmable money?
Which of the following best explains why Ethereum allows money to be programmable?
Attempts:
2 left
💡 Hint
Think about what smart contracts do on Ethereum.
✗ Incorrect
Ethereum's blockchain supports smart contracts, which are programs that run automatically and can manage money based on rules coded into them.
🔧 Debug
advanced2:00remaining
Identify the error in this Solidity function for transferring tokens
This function is intended to transfer tokens from the sender to a recipient. What error will occur when this code runs?
Blockchain / Solidity
function transfer(address to, uint amount) public {
require(balances[msg.sender] >= amount);
balances[msg.sender] -= amount;
balances[to] += amount;
}Attempts:
2 left
💡 Hint
Look at the require statement and what it checks.
✗ Incorrect
The require statement causes the transaction to revert if the sender's balance is less than the amount, preventing the transfer.
📝 Syntax
advanced1:30remaining
Which option correctly declares a payable function in Solidity?
You want to write a function that can receive Ether. Which of these function declarations is syntactically correct?
Attempts:
2 left
💡 Hint
Check the spelling and order of keywords.
✗ Incorrect
The correct syntax is
function deposit() public payable {}. The keyword 'payable' must be spelled correctly and placed after visibility.🚀 Application
expert2:30remaining
How does Ethereum ensure that smart contract code runs the same on all nodes?
Ethereum uses a special system to make sure every node runs smart contract code identically. Which mechanism achieves this?
Attempts:
2 left
💡 Hint
Think about how Ethereum achieves consensus on contract execution.
✗ Incorrect
The EVM is a virtual computer that runs the same bytecode on every node, ensuring consistent results and trustless execution.