ashablovskiy / solidity-foundry-boilerplate

⚒️ Start your next Solidity project with Foundry in seconds

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

wonderland banner


Start your next Solidity project with Foundry in seconds
A highly scalable foundation focused on DX and best practices

Features

Sample contracts
Basic Greeter contract with an external interface.
Foundry setup
Foundry configuration with multiple custom profiles and remappings.
Deployment scripts
Sample scripts to deploy contracts on both mainnet and testnet.
Sample e2e & unit tests
Example tests showcasing mocking, assertions and configuration for mainnet forking. As well it includes everything needed in order to check code coverage.
Linter
Simple and fast solidity linting thanks to forge fmt.
Github workflows CI
Run all tests and see the coverage as you push your changes.

Setup

  1. Install Foundry by following the instructions from their repository.
  2. Copy the .env.example file to .env and fill in the variables
  3. Install the dependencies by running : yarn install && forge install

Build

The default way to build the code is suboptimal but fast, you can run it via:

yarn build

In order to build a more optimized code (via IR), run:

yarn build:optimized

Running tests

Unit tests should be isolated from any externalities, while E2E usually run in a fork of the blockchain. In this boilerplate you will find example of both.

In order to run both unit and E2E tests, run:

yarn test

In order to just run unit tests, run:

yarn test:unit

In order to run unit tests and run way more fuzzing than usual (5x), run:

yarn test:unit:deep

In order to just run e2e tests, run:

yarn test:e2e

In order to check your current code coverage, run:

yarn coverage

⚠ WARNING: Forge coverage is having some issues...
As stated in this github issue, checking the code coverage with Forge when using abstract contract is not currently working.


Deploy & verify

Setup

Configure the .env variables.

Rinkeby

yarn deploy:rinkeby

Mainnet

yarn deploy:mainnet

The deployments are stored in ./broadcast

See the Foundry Book for available options.

About

⚒️ Start your next Solidity project with Foundry in seconds


Languages

Language:Solidity 97.2%Language:Shell 2.2%Language:JavaScript 0.6%