This is a template project to quickly bootstrap Ethereum application development using Foundry. Foundry is a blazing-fast, modular toolkit for Ethereum development written in Rust.
This template provides a basic setup for using Foundry's tools like Forge, Cast, Anvil, and Chisel. Whether you are building, testing, deploying, or interacting with smart contracts, this template will give you a solid foundation.
Foundry is a fast, portable, and modular toolkit for Ethereum application development. It includes:
- Forge: Ethereum testing framework (like Truffle, Hardhat, and DappTools).
- Cast: A Swiss army knife for interacting with EVM smart contracts, sending transactions, and getting chain data.
- Anvil: A local Ethereum node, similar to Ganache or Hardhat Network.
- Chisel: A fast, utilitarian Solidity REPL.
For detailed documentation, refer to the official Foundry book: Foundry Documentation
To get started with this project, make sure you have Foundry installed. If not, follow the instructions in the official documentation to set it up.
First, install Foundry by running the following command:
curl -L https://foundry.paradigm.xyz | bash
Then, run the following command to install the necessary tools:
foundryup
pre-commit
is a tool to manage and maintain multi-language pre-commit hooks. It ensures that your code is checked before committing to the repository.
Install pre-commit
using pipx
:
pipx install pre-commit
After installation, run the following command to set up pre-commit
in your project:
pre-commit install
typos
is a tool for spelling checks in your project. It helps catch common spelling mistakes in your codebase.
Install typos
with Cargo:
cargo install typos-cli
You can run it using:
typos
git-cliff
is a tool that generates changelogs from your commit history. It automatically creates a structured changelog for your project.
To install git-cliff
, run:
cargo install git-cliff
Generate a changelog using:
git cliff --output CHANGELOG.md
Title: Initialize Foundry Project
Description: This set of commands creates a new directory named my-project
, navigates into that directory, and then initializes a new Foundry project using a custom template from the specified GitHub repository.
mkdir my-project
cd my-project/
forge init --template https://github.com/qiaopengjun5162/foundry-template
To build the project, run the following command:
forge build
To run tests, use the following command:
forge test
To format your Solidity code, use:
forge fmt
To take gas snapshots of your transactions, use:
forge snapshot
To start an Anvil instance, use:
anvil
To deploy contracts using Foundry, use:
forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>
cast
is a tool to interact with Ethereum smart contracts. You can use various subcommands:
cast <subcommand>
For more information about cast
, run:
cast --help
For a list of available commands and options:
forge --help
anvil --help
cast --help
This project is licensed under the MIT License. See the LICENSE file for details.
Happy Coding! 🚀