Recall & Review
beginner
What is Ether in the context of blockchain?
Ether is the native cryptocurrency of the Ethereum blockchain. It is used to pay for transactions and computational services on the network.
Click to reveal answer
beginner
How can a smart contract receive Ether?
A smart contract can receive Ether by having a payable function or a payable fallback/receive function that allows it to accept Ether transfers.
Click to reveal answer
intermediate
What is the purpose of the 'receive() external payable' function in Solidity?
The 'receive() external payable' function is a special function in Solidity that is executed when the contract receives Ether without any data. It must be marked payable to accept Ether.
Click to reveal answer
intermediate
What happens if a contract does not have a payable fallback or receive function and someone sends Ether to it?
The transaction will fail and the Ether will be rejected because the contract cannot accept Ether without a payable function to handle it.
Click to reveal answer
beginner
How do you check the amount of Ether sent to a contract in a payable function?
You can check the amount of Ether sent using 'msg.value', which holds the amount of Wei (smallest Ether unit) sent with the transaction.
Click to reveal answer
Which keyword must a Solidity function have to accept Ether?
✗ Incorrect
Only functions marked with 'payable' can receive Ether in Solidity.
What is the special function called that handles plain Ether transfers without data?
✗ Incorrect
The 'receive()' function is called when Ether is sent without data.
What does 'msg.value' represent in a payable function?
✗ Incorrect
'msg.value' holds the amount of Ether (in Wei) sent with the transaction.
If a contract has no payable fallback or receive function, what happens when Ether is sent to it?
✗ Incorrect
Without a payable fallback or receive function, the contract rejects Ether and the transaction fails.
Which Solidity function is called when Ether is sent with data but no matching function exists?
✗ Incorrect
The 'fallback()' function is called when Ether is sent with data and no other function matches.
Explain how a smart contract can receive Ether and what functions are involved.
Think about special functions that accept Ether and how to check the amount sent.
You got /4 concepts.
Describe what happens if Ether is sent to a contract without a payable receive or fallback function.
Consider what Solidity requires to accept Ether.
You got /3 concepts.