|
| 1 | +# Foundry template |
| 2 | + |
| 3 | +Template to kickstart a Foundry project. |
| 4 | + |
| 5 | +## Getting started |
| 6 | + |
| 7 | +The easiest way to get started is by clicking the [Use this template](https://github.com/GenerationSoftware/foundry-template/generate) button at the top right of this page. |
| 8 | + |
| 9 | +If you prefer to go the CLI way: |
| 10 | + |
| 11 | +``` |
| 12 | +forge init my-project --template https://github.com/GenerationSoftware/foundry-template |
| 13 | +``` |
| 14 | + |
| 15 | +## Development |
| 16 | + |
| 17 | +### Installation |
| 18 | + |
| 19 | +You may have to install the following tools to use this repository: |
| 20 | + |
| 21 | +- [Foundry](https://github.com/foundry-rs/foundry) to compile and test contracts |
| 22 | +- [direnv](https://direnv.net/) to handle environment variables |
| 23 | +- [lcov](https://github.com/linux-test-project/lcov) to generate the code coverage report |
| 24 | + |
| 25 | +Install dependencies: |
| 26 | + |
| 27 | +``` |
| 28 | +npm i |
| 29 | +``` |
| 30 | + |
| 31 | +### Env |
| 32 | + |
| 33 | +Copy `.envrc.example` and write down the env variables needed to run this project. |
| 34 | + |
| 35 | +``` |
| 36 | +cp .envrc.example .envrc |
| 37 | +``` |
| 38 | + |
| 39 | +Once your env variables are setup, load them with: |
| 40 | + |
| 41 | +``` |
| 42 | +direnv allow |
| 43 | +``` |
| 44 | + |
| 45 | +### Compile |
| 46 | + |
| 47 | +Run the following command to compile the contracts: |
| 48 | + |
| 49 | +``` |
| 50 | +npm run compile |
| 51 | +``` |
| 52 | + |
| 53 | +### Coverage |
| 54 | + |
| 55 | +Forge is used for coverage, run it with: |
| 56 | + |
| 57 | +``` |
| 58 | +npm run coverage |
| 59 | +``` |
| 60 | + |
| 61 | +You can then consult the report by opening `coverage/index.html`: |
| 62 | + |
| 63 | +``` |
| 64 | +open coverage/index.html |
| 65 | +``` |
| 66 | + |
| 67 | +### Code quality |
| 68 | + |
| 69 | +[Husky](https://typicode.github.io/husky/#/) is used to run [lint-staged](https://github.com/okonet/lint-staged) and tests when committing. |
| 70 | + |
| 71 | +[Prettier](https://prettier.io) is used to format TypeScript and Solidity code. Use it by running: |
| 72 | + |
| 73 | +``` |
| 74 | +npm run format |
| 75 | +``` |
| 76 | + |
| 77 | +[Solhint](https://protofire.github.io/solhint/) is used to lint Solidity files. Run it with: |
| 78 | + |
| 79 | +``` |
| 80 | +npm run hint |
| 81 | +``` |
| 82 | + |
| 83 | +### CI |
| 84 | + |
| 85 | +A default Github Actions workflow is setup to execute on push and pull request. |
| 86 | + |
| 87 | +It will build the contracts and run the test coverage. |
| 88 | + |
| 89 | +You can modify it here: [.github/workflows/coverage.yml](.github/workflows/coverage.yml) |
| 90 | + |
| 91 | +For the coverage to work, you will need to setup the `MAINNET_RPC_URL` repository secret in the settings of your Github repository. |
0 commit comments