forge verify-contract and BOTScan’s Blockscout verifier.
What you’ll build
A verified contract on BOTScan testnet. The example usesCounter from the quickstart and Greeter from Deploy with Foundry, which has a constructor argument.
Prerequisites
- The Foundry project you deployed from, unchanged since the deploy. See Set up Foundry.
- The deployed contract address.
Steps
1
Verify a contract without constructor arguments
--verifier blockscoutuses BOTScan’s verifier. No API key is needed.- The verifier URL must end in
/api/, with the trailing slash. --watchwaits for the result instead of returning straight away.
Output
2
Verify a contract with constructor arguments
Encode the arguments with The values must be exactly the ones you deployed with. Forge prints the encoded
cast abi-encode and pass them with --constructor-args:Constructor args before it submits, so you can compare them with the deploy transaction’s input on BOTScan.Verify it worked
Openhttps://scan.bohr.life/address/0xYOUR_CONTRACT#code. You should see a verified badge, your source files and the compiler settings.
Mainnet
Troubleshooting
is already verified. Skipping verification.
is already verified. Skipping verification.
BOTScan already has the source, either from an earlier run or because it matched your bytecode to a contract verified before. Nothing else to do.
The verification fails with a bytecode mismatch
The verification fails with a bytecode mismatch
Your local settings differ from the deploy. Check
solc_version, optimizer, optimizer_runs and evm_version = "cancun" in foundry.toml, and the constructor arguments.A 404 or HTML error page instead of a JSON response
A 404 or HTML error page instead of a JSON response
The verifier URL is wrong. Use
https://scan.bohr.life/api/ for testnet, with /api/ and the trailing slash.Forge asks for an Etherscan API key
Forge asks for an Etherscan API key
You left out
--verifier blockscout. Forge defaults to Etherscan.Next steps
Verify in the BOTScan UI
Verify by hand when the CLI isn’t an option.
Set up wagmi
Call your verified contract from a web app.