👀Contract Verification
This guide will verify using hardhat.
Hardhat Verification Plugin
Hardhat is a full-featured development environment for contract compilation, deployment and verification. The Hardhat Etherscan plugin supports contract verification on BlockScout.
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 Asset Chain test network and a .js
file.
Asset Chain is not directly supported by the plugin (to check run npx hardhat verify --list-networks
)
But we can add it in a customChains
object, to the config file. It includes:
chainID
- 42421apiURL
- "http://scan-testnet.assetchain.org/api"browserURL
- "http://scan-testnet.assetchain.org"
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.
For info on more complex constructor arguments(arrays, tuples..) please visit here.
Example (no constructors).
Confirm Verification on BlockScout
Go to our BlockScout Explorer and paste the contract address into the search bar.
Scroll down to see verified status. A green checkmark ✅ means the contract is verified.
You can now scroll down in the explorer to see and interact with the contract code.
Congratulations! Your contract is successfully verified on Asset Chain Explorer.
Last updated