Skip to main content
Foundry is a smart contract development toolchain. Foundry manages your dependencies, compiles your project, runs tests, deploys, and lets you interact with the chain from the command line and via Solidity scripts. Forge is a command-line tool that ships with Foundry. Forge tests, builds, and deploys your smart contracts. Forge supports contract verification out of the box (https://www.getfoundry.sh/reference/forge/verify-contract).

Verify contract

In forge, contracts can be verified at the time of deployment (e.g. using forge script or forge create), or later if the contracts are already deployed (e.g. using forge verify-contract).
This guide uses the Blockscout PRO API, which covers every Blockscout-supported chain with a single key. Swap the chain_id value to move between chains, no per-chain setup required. Get a free key at dev.blockscout.com.

Tips:

  1. Specify the --verifier=blockscout flag to use the Blockscout verification provider.
  2. Specify --verifier-url="https://api.blockscout.com/v2/api?chain_id=<chain_id>", swapping <chain_id> for the chain you deployed to (e.g. chain_id=1 for Ethereum mainnet, chain_id=8453 for Base). See the full list of supported chains at dev.blockscout.com.
  3. Pass your PRO API key with --etherscan-api-key <your_pro_api_key>. Forge uses this flag name for all Etherscan-compatible verifiers, including Blockscout.
  4. You can specify most configuration options (e.g., evm version, disabling optimizations) via the usual Forge configuration.

Example (Deploy and verify)

Verify a contract with Blockscout right after deployment:
Or if using Foundry scripts:

Example (Verify already deployed contract)

Or if using Foundry scripts for the last executed script run:

Verifying against a specific instance

If you’re running a self-hosted Blockscout instance, or verifying on a chain the PRO API doesn’t cover yet, point Forge at that instance’s own API instead. No API key is required for this route.
Make sure to add /api/ to the end of the Blockscout homepage explorer URL (e.g., --verifier-url=https://eth-sepolia.blockscout.com/api/). The same --verify flag works with forge create and forge script, following the patterns above.
For the PRO API, yes. Get a free key at dev.blockscout.com. For the per-instance route, no: any non-empty string works, or you can drop --etherscan-api-key entirely.
Every Blockscout-indexed mainnet and testnet, under one key. Check the current list at dev.blockscout.com.

Resources

Learn more about Forge’s verification flags at https://www.getfoundry.sh/reference/forge/verify-contract