The Hacker contract
A hacker writes a simple and small smart contract that interacts with the EtherPot
contract by becoming one of its users. The Hacker
contract consists of similar functions to those available in the EtherPot
contract, and it mimics an externally owned account – that is, it can send Ethers, withdraw them, and check the account balance. Additionally, it also has a special receive() payable
function. This is a special function because it cannot be called on demand. It is executed automatically whenever the contract receives Ether. To receive Ether, it should be tagged as payable
:
contract Hacker { address payable etherpot; constructor(address payable _etherpot) payable { etherpot = _etherpot; } ...