Ethereum + Solidity + Hardhat + Typechain
Ethereum with Solidity contracts using Hardhat testing framework in TypeScript
- Hardhat: compile and run the smart contracts on a local development network
- TypeChain: generate TypeScript types for smart contracts
- Ethers: renowned Ethereum library and wallet implementation
- Waffle: tooling for writing comprehensive smart contract tests
- Solhint: linter
- Prettier Plugin Solidity: code formatter
This is a GitHub template, which means you can reuse it as many times as you want. You can do that by clicking the "Use this template" button at the top of the page.
- Create a
.env
file with its values:
DEPLOYER_PRIVATE_KEY=<private_key_without_0x>
INFURA_API_KEY=<SECRET_KEY>
REPORT_GAS=<true_or_false>
- Command:
- M-1:
$ npm install
(install all the packages listed insidepackage.json
) - M-2:
$ npm install --save-dev @nomiclabs/hardhat-waffle ethereum-waffle chai @nomiclabs/hardhat-ethers ethers hardhat-gas-reporter @openzeppelin/contracts typechain @typechain/ethers-v5 dotenv
- M-1:
- Contracts in the "contracts/" folder.
- Deployment scripts in the "deployment/" folder.
- Testing (locally) scripts in the "scripts/" folder.
Before running any command, make sure to install dependencies:
$ npm install
Compile the smart contracts with Hardhat:
$ npx hardhat compile
Run the Mocha tests:
$ npx hardhat test
npx hardhat run --network rinkeby ./deployment/deploy.ts
npx hardhat verify --network <network> <DEPLOYED_CONTRACT_ADDRESS> "Constructor argument 1"
- Gas reporter hardhat-gas-reporter
- Etherscan hardhat-etherscan
If you like it, then you can put a star ⭐ on the repo.