Solidity Bug Hunt Medium +20 XP
Missing payable Modifier
This function can't receive ETH.
SolidityFind the bug
1
function deposit() public {2
require(msg.value > 0);3
} The bug is on line 1
Select the correct fix
Show answer and explanation
Answer: Add payable modifier to the function
Functions must be marked payable to accept ETH. Without it, any ETH sent will cause the transaction to revert.
Hint: Only payable functions can receive Ether.
What this challenge tests
Bug Hunt in Solidity: payable, ether.