Skip to content
/ hardhat-template Public template

Solidity Smart Contract development template using modern Web3 frameworks/tools including Hardhat, Typechain and more.

License

Notifications You must be signed in to change notification settings

DeFiFoFum/hardhat-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hardhat w/ Foundry Template - by DeFiFoFum DeFiFoFum Avatar

lint & test Docs License

Solidity Smart Contract development template using modern Web3 frameworks/tools including Hardhat, Typechain and more.

Features

For testing features see README-testing.md

Deployment and Verification

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.

Configuration

  • Copy .env.example and rename to .env
    • Provide the necessary env variables before deployment/verification
    • _MNEMONIC for deployments
    • _API_KEY for verifications
  • 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.

Deployment & Verification

  1. Create a deployment script in scripts/deploy. (Use deployLock as a template.)
  2. Use DeployManager to deploy contracts to easily deploy, verify and save the output to the deployments directory.
  3. Run a deployment with npx hardhat run ./scripts/deploy/deployLock.ts --network <network>
  4. Etherscan-like API key should be stored in hardhat.config.ts under etherscan and the DeployManager can use that to verify contracts after deployment.

Linting

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 files
  • yarn lint:fix: Fix Solidity files & TS/JS files

Linting Solidity Code

  • 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

Build/Publish as NPM Package

  1. Currently this repo uses tsc to build files to dist/.
  2. 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/**/*"
  ],

Gotchas

  1. Put single quotes around globs in package.json:
    • "lint:ts": "prettier --check './{scripts,tasks,src,hardhat,test}/**/*.ts'"