Skip to main content
Hardhat is a full-featured development environment for contract compilation, deployment and verification. The hardhat-verify plugin supports contract verification on Blockscout.
This guide uses the per-instance API (no key required) rather than the Pro API. The Pro API path is in development and Blockscout’s native verification API (a separate, REST-based endpoint) isn’t compatible with hardhat-verify’s request format. Per-instance is the current working path. This is Hardhat 2 syntax — install with @nomicfoundation/hardhat-verify@hh2, since a plain install now defaults to Hardhat 3.

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-verify plugin npm
yarn
Note the @hh2 tag above — plain npm install @nomicfoundation/hardhat-verify now installs v3 (Hardhat 3), which uses a different config format entirely.

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 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 .ts 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. 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/.
Note the network name in customChains must match the network name in the apiKey object.

Verifying on multiple chains?

If you deploy to more than one network, you don’t need a separate config block per chain. Define your chains once in an array and generate networks, etherscan.apiKey, and customChains from it:
Run npx hardhat verify --list-networks at any time to confirm which network identifiers are registered in your config.

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.
Optimism Sepolia example.
If you’re using the multi-chain config, the same command works unchanged for any chain in your CHAINS array — just swap --network optimism-sepolia for --network base, --network arbitrum-one, etc.

Automatically verified contracts

Sometimes the contract may be automatically verified via Ethereum Bytecode Database service. In that case you may see the following response:
In that case, you may try to enforce using --force flag*. It prevents Hardhat from checking 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

Confirm Verification on BlockScout

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.

Video example

Community video created by Carlos Rodriguez for the Soneium Minato testnet, but can be applicable to any chain.

FAQ

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.
No. Blockscout doesn’t require a valid API key for verification through this per-instance route — any non-empty string works. Each network still needs its own entry in the apiKey object, since the network name in customChains must match a key in apiKey.
Blockscout’s separate native verification API (REST endpoints under /api/v2/smart-contracts/{address}/verification/via/...) is structurally incompatible with hardhat-verify, which only knows how to build Etherscan-shaped requests — so it can’t be dropped into this plugin without a custom script. Per-instance is the confirmed working path until one of those is sorted out with Nomic Foundation.

Resources

Learn more about plugin configs, troubleshooting etc. at https://hardhat.org/hardhat-runner/plugins/nomicfoundation-hardhat-verify