GM, anon!
"The Ethernaut is a Web3/Solidity based wargame inspired by overthewire.org, played in the Ethereum Virtual Machine. Each level is a smart contract that needs to be 'hacked'." - Ethernaut webpage
Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.
Foundry consists of:
- Forge: Ethereum testing framework (like Truffle, Hardhat and DappTools).
- Cast: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
- Anvil: Local Ethereum node, akin to Ganache, Hardhat Network.
- Chisel: Fast, utilitarian, and verbose solidity REPL.
- https://book.getfoundry.sh/
- https://blog.dixitaditya.com/series/ethernaut
- https://twitter.com/tudoratu/status/1744032551520313361
- https://twitter.com/tudoratu/status/1748351567663620512
- Google is your friend
- If you haven't already done so, install Foundry on your machine by running the following commands:
curl -L https://foundry.paradigm.xyz | bash
foundryup
- Clone the Ethernaut Foundry Solutions Repository (and remember to give it a star on Github 😉).
- Run forge build to execute the build process.
- Create a new random key pair and import it into MetaMask.
cast wallet new
- Ethernaut supports a few testnets, however we recommend solving the challenges on the Sepolia testnet using Alchemy web3 provider.
- Make a copy of .env.example and rename it to .env.
- Fill in the parameters in your .env file.
The structure of the repository is as follows:
- Under
/src
, you'll find contracts that implement solutions (attack contracts) for each challenge. - Under
/script
, there are scripts responsible for deploying the attack contracts and executing the attack. - Under
/test
, you'll find tests that validate the solutions. These tests, similar to scripts, conduct more comprehensive checks.
$ forge build
$ forge test
$ forge fmt
$ forge snapshot
$ anvil
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>
$ cast <subcommand>
$ forge --help
$ anvil --help
$ cast --help