Ethernaut is a fun game to learn blockchain development in Solidity. It consists of 25 challenges that need to be solved. I used Brownie for local testing and deploying the contracts to the Rinkeby network. Other Solidity development frameworks one can use are Truffle or Hardhat.
Here are my solutions:
- Call contribute() function with ether value > 0.001
- Call receive() function with ether value > 0: e.g. await contract.send(toWei("0.1", "ether"))
- Call withdraw()
- There is a typo in the constructor. Just call the Fal1out() functions to become the owner
- A 2nd contract (attacking contract) is used to run the logic from the actual flipping contract to predict the result and then calls the actual contract with the calculated result.
- Know the difference between tx.origin and msg.sender: tx.origin refers to the address the transaction was initiated from while msg.sender is the address that invoked the function.
- Solution: Call changeOwner() from another contract.
- The require statement in the transfer function is useless, as the left side (balances[msg.sender] - _value) of the operand is rendered as uint, which is always greater than 0.
- Solution: Call transfer with a value greater than 20.