Thanks to visit codestin.com
Credit goes to github.com

Skip to content

lambdalf-dev/web3-template

Repository files navigation

Web3 Template

A Foundry-based template for Solidity smart contract development.

What's Inside

  • Forge: compile, test, fuzz, format, and deploy smart contracts
  • Forge Std: collection of helpful contracts and utilities for testing

Getting Started

Click the Use this template button at the top of the page to create a new repository with this repo as the initial state.

Or, if you prefer to install the template manually:

$ mkdir my-project
$ cd my-project
$ forge init --template lambdalf-dev/web3-template
$ yarn install

If this is your first time with Foundry, check out the installation instructions.

Features

This template builds upon the frameworks and libraries mentioned above, so please consult their respective documentation for details about their specific features.

For example, if you're interested in exploring Foundry in more detail, you should look at the Foundry Book. In particular, you may be interested in reading the Writing Tests tutorial.

Default Settings

This template comes with a set of sensible default configurations for you to use. These defaults can be found in the following files:

├── .gitignore
├── foundry.toml
└── remappings.txt

Preconfigured Tasks

This template comes with a set of preconfigured tasks. You can find them in package.json.

Installation

This template is developped in a container so you don't need to have any tools on your computer besides your text editor. Just open the project in the container and you're ready to go.

If you prefer not to use the container, you can install the dependencies as follow:

  1. Install Foundry with
curl -L https://foundry.paradigm.xyz | bash
foundryup
  1. Install the dependencies with forge soldeer install

Writing Tests

To write a new test contract, you start by importing Test from forge-std, and then you inherit it in your test contract. Forge Std comes with a pre-instantiated cheatcodes environment accessible via the vm property. If you would like to view the logs in the terminal output, you can add the -vvvv flag and use console.log. This template comes with a TestHelper.sol that you can import in your test with useful constants and predefined users.

Prewritten contract

This template comes with a prebuilt NFT contract featuring:

  • a whitelisted free claim
  • a whitelisted private sale with its own price
  • a public sale with its own price and a general transaction limit
  • a reserve for airdrop by the team

Usage

Build/Compile

Build the contracts:

  • yarn build
  • forge build
  • forge compile

Clean

Delete the build artifacts and cache directories:

  • yarn clean
  • forge clean

Coverage

Get a test coverage report:

  • yarn coverage
  • forge coverage

Gas Report

Get a gas report:

  • yarn gas
  • forge test --gas-report

Lint

Format the contracts:

  • yarn lint
  • forge fmt check

Test

Run all tests:

  • yarn test
  • forge test

Run all tests with verbose output:

  • yarn test:verbose
  • forge test -vvvv

Run all unit tests (test name starts with "test_unit_"):

  • yarn test:unit
  • forge test --mt test_unit_

Run all fuzz tests (test name starts with "test_fuzz_"):

  • yarn test:fuzz
  • forge test --mt test_fuzz_

Run all edge tests (test name starts with "test_edge_"):

  • yarn test:edge
  • forge test --mt test_edge_

About

A Foundry-based template for Solidity smart contract development.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published