Skip to main content
In this guide you publish the source of a contract you deployed with Hardhat to BOTScan, using one command.
Everything on this page uses testnet (chain 968). Get free test tokens from the faucet.

What you’ll build

A verified Counter contract on BOTScan testnet, with its source on the Code tab.

Prerequisites

  • A Hardhat 3 project with the chainDescriptors block from Set up Hardhat. @nomicfoundation/hardhat-toolbox-viem includes the verify plugin.
  • A contract deployed from that project. See Deploy with Hardhat.

Steps

1

Check the chain descriptor

Hardhat finds BOTScan through chainDescriptors in your config. For testnet it must contain:
hardhat.config.ts
This is a fragment. The full config is in Set up Hardhat.
2

Run verify

Pass the deployed address. Use the blockscout subtask so Hardhat doesn’t ask for an Etherscan key.
You’ll see:
Output
3

Pass constructor arguments, if any

If your contract has a constructor with arguments, list them after the address in the same order:
For complex arguments, see the Hardhat docs on verifying contracts.

Verify it worked

Open the Explorer link from the output. The Code tab shows a verified badge, your source and the compiler settings. The Read contract tab lets you call count.

Troubleshooting

You ran npx hardhat verify without blockscout, so Hardhat tried Etherscan too. Add the blockscout subtask.
The chainDescriptors entry is missing or uses a different chain ID. Add the block from step 1.
The local build differs from what you deployed. Don’t change the source or compiler settings between deploying and verifying. If you did, redeploy and verify again.
The contract is verified, either by an earlier run or because BOTScan matched your bytecode to a contract verified before. Nothing else to do. Hardhat suggests --force only for partially verified contracts.

Next steps

Verify in the BOTScan UI

Verify by hand when the CLI isn’t an option.

Explorer API

Read verified contract data from BOTScan’s API.
Last modified on October 3, 2026