An open API service indexing awesome lists of open source software.

https://github.com/johnsaigle/ethernaut-solutions

Solutions to the "Ethernaut" smart contract security CTF.
https://github.com/johnsaigle/ethernaut-solutions

ethernaut smart-contracts solidity

Last synced: 3 months ago
JSON representation

Solutions to the "Ethernaut" smart contract security CTF.

Awesome Lists containing this project

README

        

# ethernaut-solutions

Solutions to [Ethernaut CTF](https://ethernaut.openzeppelin.com/)/LiftTicket for Avax.

The unit-test solution format is based on the work done by [MrToph](https://github.com/MrToph)
Check out his work! His blog posts helped me to get started with smart contract
auditing. This repository uses unit tests instead of cloning Ethernaut as-is.
For a beginner, this greatly simplifies the deployment and build process.

## Current Progress

- [x] 0-Hello.sol _(but not in this repo)_
- [x] 1-Fallback.sol _(but not in this repo)_
- [x] 2-Fallout.sol _(but not in this repo)_
- [x] 3-CoinFlip.sol
- [x] 4-Telephone.sol
- [x] 5-Token.sol
- [x] 6-Delegation.sol
- [x] 7-Force.sol
- [x] 8-Vault.sol
- [x] 9-King.sol
- [x] 10-ReEntrancy.sol
- [x] 11-Elevator.sol
- [x] 12-Privacy.sol
- [x] 13-GatekeeperOne.sol
- [x] 14-GatekeeperTwo.sol
- [x] 15-NaughtCoin.sol
- [x] 16-Preservation.sol
- [x] 17-Recovery.sol
- [x] 18-MagicNumber.sol
- [x] 19-AlienCodex.sol
- [x] 20-Denial.sol
- [x] 21-Shop.sol

_I may attempt and add solutions to the more recent puzzles in the future._

## Development

```bash
npm i
```

You need to configure environment variables:

```bash
cp .env.template .env
# fill out
```

Pick a mnemonic and the resulting accounts will be used in the challenges.

#### Hardhat

This repo uses [hardhat](https://hardhat.org/) to run the CTF challenges.
Challenges are implemented as hardhat tests in [`/test`](./test).

The tests run on a local hardnet network but it needs to be forked from Rinkeby because it interacts with the challenge factory and submission contract.
To fork the Rinkeby testnet, you need an archive URL like the free ones from [Alchemy](https://alchemyapi.io/).

#### Running challenges

Optionally set the block number in the `hardhat.config.ts` hardhat network configuration to the rinkeby head block number such that the challenge contract is deployed.

```bash
# fork rinkeby but run locally
npx hardhat test test/0-hello.ts
```