OpenZeppelin Ethernaut but with the front end stripped out and all tests left blank to practice breaking Solidity contracts.
After installing Foundry, you will need to install both an older and a newer version of openzeppelin contracts:
forge install openzeppelin-contracts-06=OpenZeppelin/openzeppelin-contracts@v3.3.0 --no-commit
forge install openzeppelin-contracts-08=OpenZeppelin/openzeppelin-contracts@v4.4.1 --no-commit
forge install OpenZeppelin/openzeppelin-contracts-upgradeable --no-commit
forge install foundry-rs/forge-std --no-commit
Don't change the versions above as there are differences which will cause build to fail.
Compile everything with forge build
Some challenges will require you to write a new contract to help with your attack (e.g. Telephone). Write these additional contracts in src/attacks/<Challenge Name>Attack.sol
.
Note on tests: Code contains additional sanity-check type of tests which you are not supposed to interact with so that is why I suggest using the
--mt testSolve
option.
I suggest testing problems as you go. So, for example, if you are working on Fallback, you would test your code with below command:
forge test --mt testSolve --mc Fallback
Or more generally:
forge test --mt testSolve --mc <contract_name_here>
Run below to test your solution to all Ethernaut problems:
forge test --mt testSolve