Ethernaut Challenge 2 Walkthrough w Code

Challenge 2

The key knowledge for this challenge is to know that Constructors are declared using the constructor keyword or a function with the same name as the contract, in this case Fallout, as the contract name is Fallout.sol.

Misnamed Function

However, in the image above, there is an error in constructor function naming which is misnamed Fal1out instead of Fal1out. This caused the function to be a public function instead of a constructor function.

Therefore all we need to do to exploit is to call await contract.Fal1out()

Solutions :

Hope that this short and sweet tutorial helped!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Yong kang Chia

Yong kang Chia

My name is Yong Kang and I am a self-taught programmer. I have been doing freelance web and app development on the site. Currently a freelance software dev.