Get Started
1) Install Hardhat
If you are starting from scratch, create an npm project by going to an empty folder, runningnpm init
, and following the instructions. Recommend npm 7 or higher.
Once your project is ready:
npm instructions
2) Create a project
Runnpx hardhat
in your project folder and follow the instructions to create (more info here).
3) Install plugin
Install the hardhat-verify plugin npm4) Add plugin reference to config file
Add the following statement to yourhardhat.config.js
.
hardhat.config.ts.
More info on using typescript with hardhat available here.
Config File and Unsupported Networks
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 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. More info.
If you prefer, you can migrate to hardhat-toolbox to use a plugin bundle.
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
Find an extensive list of ChainIDs at https://chainlist.org/.
customChains
must match the network name in the apiKey
object.
Deploy and Verify
For deployment we will use Hardhat Ignition - built-in Hardhat deployment system.Deploy
Verify
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.Automatically verified contracts
Sometimes the contract may be automatically verified via Ethereum Bytecode Database service. In that case you may see the following response:--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/[email protected]
Confirm Verification on BlockScout
Go to your BlockScout instance and paste the contract address into the search bar.



Video example
Community video created by Carlos Rodriguez for the Soneium Minato testnet, but can be applicable to any chain.FAQ
I am using an OpenZeppelin upgrades plugin implementation and receive an error on proxy contract verification. What should I do?
I am using an OpenZeppelin upgrades plugin implementation and receive an error on proxy contract verification. What should I do?
Although you receive an error, the contracts should be verified during the previous steps and you can ignore. Check in the explorer to make sure the contracts have been verified.
Resources
Learn more about plugin configs, troubleshooting etc. at https://hardhat.org/hardhat-runner/plugins/nomicfoundation-hardhat-verify