Hardhat Verification Plugin
Last updated
Was this helpful?
Last updated
Was this helpful?
is a full-featured development environment for contract compilation, deployment and verification. The supports contract verification on BlockScout.
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
Run npx hardhat
in your project folder and follow the instructions to create ().
Install the
npm
yarn
Add the following statement to your hardhat.config.js
.
In order to use Blockscout explorer for the verification, you have to specify the explorer details under a customChains
object. It includes:
chainID
- Network chain ID
apiURL
- Block explorer API URL
browserURL
- Block explorer URL
For example, here we added Blockscout api endpoints for the Optimism Sepolia network to the config file. Note the network name in customChains
must match the network name in the apiKey
object.
The plugin requires you to include constructor arguments with the verify task and ensures that they correspond to expected ABI signature. However, Blockscout ignores those arguments, so you may specify any values that correspond to the ABI.
Optimism Sepolia example.
In that case, you may try to enforce using --force
flag*.
It prevents Hardhat to check if the contract is already verified, and force it to send verification request anyway. Notice, that it is helpful only if the contract was automatically verified partially. That way, a new verification sources would be saved. If the contract was fully verified already, that just returns an error.
The flag is available starting from @nomicfoundation/hardhat-verify@2.0.7
Go to your BlockScout instance and paste the contract address into the search bar.
Scroll down to see verified status. A green checkmark ✅ means the contract is verified.
If your screen size is limited, you may need to click the 3 dots to view and click through to the contract.
Scroll down to see and interact with the contract code.
Community video created by Carlos Rodriguez for the Soneium Minato testnet, but can be applicable to any chain.
If using TypeScript, add this to your hardhat.config.ts.
.
Your basic (hardhat.config.js
or hardhat.config.ts
) will be setup to support the network you are working on. In this example we use the Optimism Sepolia 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. .
If you prefer, you can migrate to to use a plugin bundle.
Find an extensive list of ChainIDs at .
For deployment we will use - built-in Hardhat deployment system.
Sometimes the contract may be automatically verified via service. In that case you may see the following response:
Learn more about plugin configs, troubleshooting etc. at