Minimalist workspace with Foundry and ethers to test Ethernaut CTF solutions.
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'. The game is 100% open source and all levels are contributions made by other players. It operates on Sepolia Testnet.
The structure of this repository is modeled from the method used to test Ethernaut solutions in their official repository. I was also inspired by StErMi/foundry-ethernaut repo.
This is just my personal workspace which I decide to tidy-up a bit and make it public. Submissions of actual level instances are managed externally from this codebase. My player address is 0xA7a47ce31946D2d67196f0C95EC6314Df12FbCfa
.
git@github.com:sofinico/some-ethernaut-solutions.git
cd some-ethernaut-solutions
Foundry deps
git submodule update --init --recursive
Node deps
npm install
forge test -vvv --match-contract TestLevelName
Tests contracts naming convention is Test
+ LevelName
, i.e, TestNaughtCoin
.
-vvv
flag is to show logs, but can be removed.
Run all solutions tests with Foundry
forge test
Some .ts files are present in test
directory. These are helper scripts; sometimes tests and others just helpers to understand what was going on. To run these custom tests/helpers (coded using typescript + ethers), do
npm test LevelName.ts
Version naming:
openzeppelin-contracts-06
corresponds tov3.4.2
;openzeppelin-contracts-08
corresponds tov4.7.3
.
This is analogous as how it is done in ethernaut repo. This versioning install is done for example:
forge install openzeppelin-contracts-06=OpenZeppelin/openzeppelin-contracts@v3.4.2