Bird
Raised Fist0
Blockchain / Solidityprogramming~10 mins

Why Ethereum enables programmable money in Blockchain / Solidity - Visual Breakdown

Choose your learning style10 modes available
Concept Flow - Why Ethereum enables programmable money
User wants to send money
↓
Create transaction with rules
↓
Send to Ethereum network
↓
Smart contract checks rules
↓
If rules pass, transfer funds
↓
Update blockchain state
↓
Transaction complete
Ethereum lets users write rules (smart contracts) that control how money moves, making money programmable.
Execution Sample
Blockchain / Solidity
contract SimplePayment {
  function pay(address recipient) public payable {
    require(msg.value > 0, "Send some ETH");
    payable(recipient).transfer(msg.value);
  }
}
This smart contract lets someone send ETH to a recipient only if some ETH is sent.
Execution Table
StepActionInputCondition CheckResultBlockchain State
1User calls pay()recipient=0xABC, msg.value=1 ETHmsg.value > 0?TrueNo change yet
2Contract transfers ETH1 ETH to 0xABCN/ATransfer successBalance of 0xABC +1 ETH
3Update blockchainRecord transactionN/ATransaction recordedState updated with new balances
4Transaction completeN/AN/ASuccessFinal state with transferred ETH
💡 Transaction ends after successful transfer and blockchain state update
Variable Tracker
VariableStartAfter Step 1After Step 2After Step 3Final
msg.value01 ETH1 ETH1 ETH1 ETH
recipient balanceX ETHX ETHX+1 ETHX+1 ETHX+1 ETH
contract balanceY ETHY+1 ETHY ETHY ETHY ETH
Key Moments - 2 Insights
Why does the contract check if msg.value > 0 before sending ETH?
The contract ensures some ETH is sent to avoid empty or invalid transfers, as shown in step 1 of the execution_table where the condition must be true to proceed.
How does Ethereum update balances after the transfer?
After the transfer action in step 2, the blockchain state updates balances, reflected in step 3 where the new balances are recorded.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the condition checked at step 1?
Acontract balance > 0
Brecipient address is valid
Cmsg.value > 0
Dtransaction gas limit
💡 Hint
Check the 'Condition Check' column at step 1 in the execution_table
At which step does the recipient's balance increase?
AStep 2
BStep 1
CStep 3
DStep 4
💡 Hint
Look at the 'Result' and 'Blockchain State' columns in the execution_table for step 2
If msg.value was 0, what would happen according to the execution flow?
ATransfer would still happen
BTransaction would fail at condition check
CRecipient gets 0 ETH
DBlockchain state updates anyway
💡 Hint
Refer to step 1 condition check in the execution_table and key_moments explanation
Concept Snapshot
Ethereum uses smart contracts to make money programmable.
Users send transactions with rules.
Contracts check conditions before transferring ETH.
Blockchain updates state only if rules pass.
This enables complex money behaviors beyond simple transfers.
Full Transcript
Ethereum enables programmable money by letting users write smart contracts that control how funds move. When a user sends a transaction calling a contract function, the contract checks conditions like whether some ETH was sent. If conditions are met, the contract transfers ETH to the recipient and updates the blockchain state. This process ensures money moves only as programmed, allowing complex financial rules to run automatically on Ethereum.

Practice

(1/5)
1. Why does Ethereum enable money to be programmable?
easy
A. Because it uses smart contracts that run code automatically
B. Because it stores money only in physical wallets
C. Because it requires banks to approve transactions
D. Because it uses paper currency for transactions

Solution

  1. Step 1: Understand Ethereum's core feature

    Ethereum uses smart contracts, which are pieces of code that run automatically on the blockchain.
  2. Step 2: Connect smart contracts to programmable money

    Smart contracts can control money by following rules written in code, making money programmable without middlemen.
  3. Final Answer:

    Because it uses smart contracts that run code automatically -> Option A
  4. Quick Check:

    Smart contracts = Programmable money [OK]
Hint: Smart contracts run code to control money automatically [OK]
Common Mistakes:
  • Thinking Ethereum uses physical wallets only
  • Assuming banks approve Ethereum transactions
  • Confusing Ethereum with paper currency systems
2. Which of the following is the correct way to define a simple smart contract function in Solidity that sends Ether?
easy
A. function sendEther(payable recipient) public payable { recipient.send(msg.value); }
B. function sendEther(address payable recipient) public payable { recipient.transfer(msg.value); }
C. function sendEther(address recipient) private { recipient.transfer(msg.value); }
D. function sendEther(address recipient) public { recipient.send(msg.value); }

Solution

  1. Step 1: Check function signature for sending Ether

    The function must be public and payable to receive and send Ether, and the recipient must be declared payable.
  2. Step 2: Verify the transfer method usage

    Using recipient.transfer(msg.value) correctly sends the Ether amount received in the call.
  3. Final Answer:

    function sendEther(address payable recipient) public payable { recipient.transfer(msg.value); } -> Option B
  4. Quick Check:

    Payable recipient + public payable function + transfer = Correct [OK]
Hint: Use 'address payable' and 'payable' function to send Ether [OK]
Common Mistakes:
  • Missing 'payable' keyword on function or address
  • Using 'send' without checking return value
  • Declaring function as private when it should be public
3. What will be the output of this Solidity code snippet when the function checkBalance() is called after sending 5 Ether to the contract?
contract Wallet {
    uint public balance;
    function deposit() public payable {
        balance += msg.value;
    }
    function checkBalance() public view returns (uint) {
        return balance;
    }
}
medium
A. 5000000000000000000
B. 5
C. 0
D. Compilation error

Solution

  1. Step 1: Understand msg.value unit in Solidity

    Ether values in Solidity are handled in wei, where 1 Ether = 10^18 wei.
  2. Step 2: Calculate balance after deposit

    Sending 5 Ether means msg.value = 5 * 10^18 wei = 5000000000000000000 wei, which is added to balance.
  3. Final Answer:

    5000000000000000000 -> Option A
  4. Quick Check:

    5 Ether = 5 * 10^18 wei = 5000000000000000000 [OK]
Hint: Remember Ether is in wei (1 Ether = 10^18 wei) [OK]
Common Mistakes:
  • Returning Ether as 5 instead of wei
  • Confusing balance with contract's actual Ether balance
  • Expecting output in Ether units without conversion
4. Identify the error in this Solidity smart contract code that tries to send Ether to an address:
contract Pay {
    function payTo(address recipient) public payable {
        recipient.transfer(msg.value);
    }
}
medium
A. transfer() cannot be used to send Ether
B. The function should not be payable
C. msg.value cannot be used inside the function
D. The recipient address must be declared payable

Solution

  1. Step 1: Check recipient address type

    In Solidity, to send Ether, the recipient address must be declared as payable.
  2. Step 2: Identify missing payable keyword

    The code uses 'address recipient' instead of 'address payable recipient', causing a compilation error.
  3. Final Answer:

    The recipient address must be declared payable -> Option D
  4. Quick Check:

    Address payable needed to send Ether [OK]
Hint: Use 'address payable' for recipients receiving Ether [OK]
Common Mistakes:
  • Forgetting 'payable' on recipient address
  • Thinking transfer() is invalid
  • Removing payable from function incorrectly
5. You want to create a smart contract that automatically sends 1 Ether to a specific address every time it receives at least 2 Ether. Which approach best uses Ethereum's programmable money feature?
hard
A. Use an external script to monitor the contract and send Ether when balance is 2 Ether
B. Manually send Ether from your wallet to the address after receiving 2 Ether
C. Write a payable function that checks if msg.value >= 2 Ether, then sends 1 Ether to the address using transfer()
D. Set a timer outside Ethereum to send Ether every day

Solution

  1. Step 1: Use smart contract code to automate sending

    Writing a payable function that checks the amount received and sends Ether automatically uses Ethereum's programmable money feature.
  2. Step 2: Avoid manual or external triggers

    Manual sending or external scripts do not leverage Ethereum's automatic, trustless execution.
  3. Final Answer:

    Write a payable function that checks if msg.value >= 2 Ether, then sends 1 Ether to the address using transfer() -> Option C
  4. Quick Check:

    Smart contract automation = programmable money [OK]
Hint: Automate with payable function and transfer() inside contract [OK]
Common Mistakes:
  • Relying on manual or external triggers
  • Not using payable functions for receiving Ether
  • Ignoring automatic code execution on Ethereum
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard