EVM-based Smart Contract Scaffold
A Typescript Hardhat-based template to develop evm-based smart contracts with all the tooling you need.
Features
- Uses hardhat-deploy to keep track of deployments (upgradable or normal)
- Uses typechain to auto-generate typescript bindings for compiled contracts, useful for auto-completion in your frontend dApps
- Uses semantic-release and commitlint for a streamline CI
- Uses Github Actions to publish versioned contracts to NPM, along with their Typescript bindings, ABIs (useful for interacting from your dApp) and bytecodes (useful when deploying contracts using ethers.js or web3).
- Supports multiple chains
- Gas cost reporter using CoinMarketCap APIs for your contract deployment and each interaction
- Contract size calculator plugin for Hardhat
- Automated Etherscan verification for deployed contracts
Getting Started
-
Clone this repo (or click on "Use Template" button above in Github), then update the .github/CODEOWNERS
:
git clone https://github.com/0xflair/evm-contract-scaffold my-amazing-contracts
vi my-amazing-contracts/.github/CODEOWNERS
-
Create a .env
file based on .env.example
and update the values.
-
Create your first contract in src/
.
-
Compile the contracts:
npm run compile
Deploying
When you are ready, let's deploy the contract on the blockchain and have it verified in corresponding block scanner.
-
Deploy the contracts:
npm run deploy:rinkeby
-
Verify the contracts on Etherscan:
npm run verify:rinkeby
Releasing
If you want your contract to be released as an NPM package you can:
- Create a new Automation token in your NPM account.
- Add a new secret called
NPM_TOKEN
in your Github repository > Settings > Secrets > Actions. - Commit anything on
main
branch then automatically you'll get a new release.
Ensure your main branch is either does not require status checking, or has "bypass" exception for semantic-release-bot so that it can push new tags and releases on the Github repo.
Testing
-
Write your tests in test/
directory.
-
Execute them:
npm run test
License
This repository is under MIT license.