I created this project as a reminder or, if you like, a template for future projects.
This project uses and is ready to configure the following plugins:
- solidity-coverage - coverage of contract code with tests
- hardhat-gas-reporter - gas cost estimate, uses CoinMarketCap to get prices
- hardhat-etherscan - to verify contracts on Etherscan/Bscscan/etc
Also in hardhat.config.json
I added the setting for working with the actual Goerli test network using the Alchemy service.
WARNING: copy .env.example
to .env
!
The following commands have been used:
mkdir {project}
cd {project}
npm init
npm install --save-dev hardhat
npx hardhat
npx hardhat clean && npx hardhat compile
npx hardhat test [--grep text]
REPORT_GAS=true npx hardhat test
npx hardhat coverage
In test code, you can add .only
to it
to run a specific test, or you can use grep
in the console when calling the tests.
The tasks code is in the tasks
folder, the launch examples is in the code.
npx hardhat node
npx hardhat run scripts/deploy.js --network localhost
There is ALCHEMY_FORK_API_KEY
parameter in the .env.example
should be set.
npx hardhat node --config hardhat-fork.config.js
npx hardhat verify --network goerli {contractAddress}
For convenience, in order not to write npx hardhat
and commands are automatically substituted, you can:
sudo npm install --global hardhat-shorthand
hardhat-completion install
Now you can type commands as follows by finishing them with TAB:
> hh te[press TAB]
> hh test