0
0
Blockchain / Solidityprogramming~20 mins

Why Ethereum enables programmable money in Blockchain / Solidity - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Ethereum Programmable Money Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2: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];
    }
}
A0
BRevert error at runtime
CCompilation error
D100
Attempts:
2 left
💡 Hint
Think about what the constructor does when the contract is deployed.
🧠 Conceptual
intermediate
1:30remaining
Why does Ethereum enable programmable money?
Which of the following best explains why Ethereum allows money to be programmable?
AEthereum uses a blockchain that supports smart contracts, which are self-executing code that can control digital assets automatically.
BEthereum stores all money in a single centralized database controlled by one company.
CEthereum only supports simple transactions without any code execution.
DEthereum requires manual approval for every transaction by a central authority.
Attempts:
2 left
💡 Hint
Think about what smart contracts do on Ethereum.
🔧 Debug
advanced
2: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;
}
ANo error, the function works correctly.
BRevert error if balances[msg.sender] is less than amount.
CCompilation error due to missing return type.
DRuntime error if balances[to] overflows uint limit.
Attempts:
2 left
💡 Hint
Look at the require statement and what it checks.
📝 Syntax
advanced
1: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?
Afunction deposit() payable public {}
Bfunction deposit() public payble {}
Cfunction deposit() public payable {}
Dfunction deposit() public payable returns (uint) {}
Attempts:
2 left
💡 Hint
Check the spelling and order of keywords.
🚀 Application
expert
2: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?
AEthereum uses the Ethereum Virtual Machine (EVM) which executes bytecode deterministically on all nodes.
BEthereum relies on each node running different code versions to increase diversity.
CEthereum nodes execute smart contracts using local machine instructions that vary by hardware.
DEthereum uses a centralized server to run all smart contract code and broadcast results.
Attempts:
2 left
💡 Hint
Think about how Ethereum achieves consensus on contract execution.