Hardhat w/ Foundry Template - by DeFiFoFum
Solidity Smart Contract development template using modern Web3 frameworks/tools including Hardhat, Typechain and more.
For testing features see README-testing.md
- Foundry Smart Contract Development ToolChain
- See README-foundry.md for more info.
- Contract Support
- OpenZeppelin Contracts: Trusted smart contract standards
- Openzeppelin Contracts Upgradeable: Upgradeable smart contract support
- Safe Wallet: Deploy Safe Wallets to the same address on multiple networks. (See README-safe.md for more info.)
- Typescript
- Typechain: Generate smart contract typings for Ethers during
- Docs
- Solidity Docgen: Generate markdown files from the NatSpec comments in your Solidity code.
- OR
- Hardhat Docgen: Generate a static documentation site from NatSpec comments automatically on compilation with Hardhat. compilation.
- Linting
- Prettier: Most popular opinionated code formatter.
- Prettier Solidity plugin: A Prettier plugin for automatically formatting your Solidity code.
- Solhint: Open source project for linting Solidity code. This project provides both Security and Style Guide validations.
- solhint.config.ts is full featured and support Solidity style guide recommendations.
- Hardhat Contract Sizer
- Build/Publish as NPM Package: This repo is setup to build important files into a publishable NPM package. (See below for more info)
This project uses special tasks, adapted from Balancer protocol, to deploy and verify contracts which provides methods for saving custom outputs and easily verifying contracts as well as compartmentalizing different types of deployments.
- Copy .env.example and rename to
.env
- Provide the necessary
env
variables before deployment/verification _MNEMONIC
for deployments_API_KEY
for verifications
- Provide the necessary
- hardhat.config.ts: Can be configured with additional networks if needed
- hardhat/types.ts: Holds network typings which can be updated with more networks.
- Configure Deployment Variables for each network in deploy.config.ts.
- Ensure Etherscan API Keys are configured in hardhat.config.ts under
etherscan
.
- Create a deployment script in scripts/deploy. (Use deployLock as a template.)
- Use DeployManager to deploy contracts to easily deploy, verify and save the output to the deployments directory.
- Run a deployment with
npx hardhat run ./scripts/deploy/deployLock.ts --network <network>
- Etherscan-like API key should be stored in hardhat.config.ts under
etherscan
and the DeployManager can use that to verify contracts after deployment.
This project uses Prettier, an opinionated code formatter, to keep code styles consistent. This project has additional plugins for Solidity support as well.
yarn lint
: Check Solidity files & TS/JS filesyarn lint:fix
: Fix Solidity files & TS/JS files
-
prettier.config.js: Provide config settings for Solidity under
overrides
. -
.solhint.json: Provide config settings for
solhint
. -
yarn lint:sol
: Check Solidity files -
yarn lint:sol:fix
: Fix Solidity files
- Currently this repo uses
tsc
to build files todist/
. - Files are cherry picked in package.json under
files
as there are a lot of support files included in this repo.
Consider including only what is needed.
"files": [
"dist/index.js",
"dist/index.d.ts",
"dist/src/**/*",
"dist/typechain-types/**/*",
// "dist/artifacts/**/*"
],
- Put single quotes around globs in
package.json
:"lint:ts": "prettier --check './{scripts,tasks,src,hardhat,test}/**/*.ts'"