Member-only story
How to solve Ethernaut challenges #1: Levels 1 to 5

Let’s play with Ethernaut and learn to hack Solidity together. I will go through how to complete the levels and I will be providing any additional resources to extend the knowledge or to prepare you to complete the challenge by yourself. In this post we will go through levels 1 to 5.
Before starting, a few tips:
- In order to interact with the game you need to open Developer Tools from your browser
- Before starting the levels you need to click on ‘Get new instance’ which will deploy the contract so you can interact with it
- You can copy and paste the code to Remix
Level 1 — Fallback
Objective 1: Claim ownership of the contract
The part that interests you the most is the function receive()
because there is where the owner gets assigned to msg.sender
and that should tell you that somehow if you enter it you can get the ownership of the contract.
More info on receive function here
Once you have created the new instance, you can go to developer tools and write contract.address
. With that address go to Remix and after compiling, go to the deploy tab and paste the contract’s address in the field “At address”.
Next steps will be:
- Click on “At address” to deploy contract
- Add a value of 1 wei and click on Contribute from the deployed contract
- Next we need to call function
Receive
in order to do that you need to click on the transact button leaving the calldata field empty but before that ad 1 wei to value field.
Now, you have already claimed the ownership of the contract.
Objective 2: Reduce it’s balance to 0
Simple, now you can click on withdraw and take all wei from the contract.
Done.
Level 2 — Fallout
Objective: Claim ownership of the contract
First thing to notice is the solidity version it is used which is related to the way the contract calls its constructor.
In older version the keyword
constructor()
wasn’t used…