What you’ll build
A verifiedCounter contract on BOTScan testnet, with its source on the Code tab.
Prerequisites
- A Hardhat 3 project with the
chainDescriptorsblock from Set up Hardhat.@nomicfoundation/hardhat-toolbox-viemincludes the verify plugin. - A contract deployed from that project. See Deploy with Hardhat.
Steps
1
Check the chain descriptor
Hardhat finds BOTScan through This is a fragment. The full config is in Set up Hardhat.
chainDescriptors in your config. For testnet it must contain:hardhat.config.ts
2
Run verify
Pass the deployed address. Use the You’ll see:
blockscout subtask so Hardhat doesn’t ask for an Etherscan key.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 callcount.
Troubleshooting
Hardhat asks for an Etherscan API key
Hardhat asks for an Etherscan API key
You ran
npx hardhat verify without blockscout, so Hardhat tried Etherscan too. Add the blockscout subtask.No block explorer configured for chain 968
No block explorer configured for chain 968
The
chainDescriptors entry is missing or uses a different chain ID. Add the block from step 1.The bytecode doesn't match
The bytecode doesn't match
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.
has already been verified on BOTScan Testnet
has already been verified on BOTScan Testnet
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.