This project includes some additional Hardhat plugins and project structuring which isn't included in the standard project generated by the npx hardhat
command, the additions are outlined below.
In order for this codebase to operate, rename .env.example
to .env
and fill in the environment variables (never commit your .env
file to your repository, the .env
file will be ignored by default by .gitignore
).
The following additional Hardhat plugins are included with this project:
This official plugin made by Nomic Foundation, developers behind Hardhat, is used to make it easier to verify your contracts within your Hardhat project on Etherscan. This plugin makes use of the ETHERSCAN_API_KEY
in the .env
file (see .env.example
).
An example of usage of this functionality is shown in scripts/sample-deployment.js.
In-depth usage instructions on repo | npm
This community plugin made by Christopher Gewecke is used to make it easier to keep track of the gas usage of your Solidity code. Upon running tests, this plugin will automatically output gas-usage statistics based off the different method calls and deployments completed by your tests (runs by default during npx hardhat test
).
In-depth usage instructions on repo | npm
This community plugin made by Nick Barry is used to make it easier to keep track of the different sizes of your contracts, this helps to make sure that no contracts exceed the 24576 byte
limit imposed by EIP-170 in Ethereum's Spurious Dragon hard fork. It also improves the experience of making different optimizations to your Solidity code in order to decrease deployment costs (e.g. seeing the impact of using shorter revert messages). Runs by default upon running npx hardhat test
.
In-depth usage instructions on repo | npm
This community plugin, also made by Christopher Gewecke, via sc-forks, is used to make it easier to keep track of which parts of your Solidity codebase have been covered by your test cases as well as which parts have not been covered.
In order to generate a coverage report, run npx hardhat coverage
, the .gitignore folder will ignore the coverage files so if you would like to commit them to your repo, adjust the .gitignore
accordingly (by removing references to coverage
).
In-depth usage instructions on repo | npm
This common Javascript module made by Mot is used to load environment variables from .env
files into the runtime of your codebase (in this case we use the .env
to populate environment data in our hardhat.config.js
file, this also makes it easier for code secrets to be kept in one place and to avoid committing secrets to the codebase repo by virtue of .env
being ignored in .gitignore
).
In-depth usage instructions on repo | npm
This collection of Solidity Contracts curated and maintained by the team at OpenZeppelin often come in handy when building new contracts, as they handle common operations in a safety-checked way.
These can be imported in the following way within new Solidity files:
import "@openzeppelin/contracts/access/Ownable.sol";
In-depth usage instructions on docs | repo | npm
npx hardhat accounts
npx hardhat compile
npx hardhat clean
npx hardhat test
npx hardhat node
node scripts/sample-script.js
npx hardhat help