Hardhat Plugin
Hardhat Verification Plugin
Hardhat is a full-featured development environment for contract compilation, deployment and verification. The Hardhat Etherscan plugin supports contract verification on Gauss Explorer.
Get Started
1) Install Hardhat
If you are starting from scratch, create an npm project by going to an empty folder, running npm init
, and following the instructions. Recommend npm 7 or higher.
Once your project is ready:
npm instructions
yarn instructions
2) Create a project
Run npx hardhat
in your project folder and follow the instructions to create (more info here).
3) Install plugin
Install the hardhat-etherscan plugin (requires v3.0.0+).
npm
yarn
4) Add plugin reference to config file
Add the following statement to your hardhat.config.js
.
If using TypeScript, add this to your hardhat.config.ts.
More info on using typescript with hardhat available here.
Config File
Your basic Hardhat config file (hardhat.config.js
or hardhat.config.ts
) will be setup to support the network you are working on. In this example we use the G.I.L. test network and a .js
file.
Here we add an RPC url without an API key, however some value is still required. You can use any arbitrary string. More info.
If you prefer, you can migrate to hardhat-toolbox to use a plugin bundle.
Add an Unsupported Network
Some chains are not supported by the plugin (to check run npx hardhat verify --list-networks
)If your chain is not in the list, you can add a customChains
object to the config file. It includes:
chainID
- Network chain IDapiURL
- Block explorer API URLbrowserURL
- Block explorer URL
Find an extensive list of ChainIDs at https://chainlist.org/
For example, if G.I.L. were not in the default list, this is how it would be added to the config file. Note the network name in customChains
must match the network name in the apiKey
object.
Deploy and Verify
Deploy
Verify
You can include constructor arguments with the verify task.
G.I.L. example (no constructors).
Note the verify task will not be listed in the available tasks lists at npx hardhat --config
but should work as expected.
If not, check you have the minimum required version of the nomiclabs-hardhat-etherscan plugin (v3.0.0+) installed
Confirm Verification on Gauss Explorer
Go to your Gauss Explorer instance and paste the contract address into the search bar. If verified, the code tab will display a green checkmark.
Selecting the Code tab will provide additional information about your contract.
Resources
Learn more about plugin configs, troubleshooting etc. at https://hardhat.org/plugins/nomiclabs-hardhat-etherscan.html
Last updated