Skip to main content
Contract verification makes your contract source code publicly available on block explorers, enabling transparency and allowing users to interact with contracts directly through explorer interfaces.

Why Verify Contracts?

  • Transparency: Users can inspect contract source code
  • Trust: Verification proves deployed bytecode matches public source
  • Interaction: Block explorers provide UI for contract interaction
  • Debugging: Easier to debug transactions with verified contracts
  • Integration: Required for some integration tools and services

Automated Verification

Using Verification Script

The easiest way to verify all deployed contracts:
This script will:
  • Read deployment data from CSV file
  • Load verification API keys from configuration
  • Verify each contract on its respective block explorer
  • Retry failed verifications automatically
  • Provide detailed verification summary

Prerequisites for Automated Verification

1

Deployment Results File

Ensure RESULTS_FILE exists with deployment data:
Expected format:
2

Configure Verification Keys

Create verification keys file or set environment variable:Option 1: JSON File
verification-keys.json
Option 2: Environment Variable
3

Set Environment Variables

.env

Verification Script Features

Automatic Header Removal
  • Detects and removes CSV headers before processing
Retry Logic
  • Retries failed verifications with 5-second delay
  • Useful for rate limiting or temporary explorer issues
RPC URL Integration
  • Uses chain data for more reliable verification
  • Falls back to explorer defaults if not available
Progress Tracking
  • Shows verification progress (e.g., “2 of 5”)
  • Provides summary statistics at end
Constructor Arguments
  • Automatically includes constructor args from deployment data
  • Handles contracts with no constructor args

Manual Verification

Verify Using Forge

Verify a single contract manually:

Verification Flags Explained

Constructor Arguments

For contracts with constructor parameters, you need to provide ABI-encoded arguments. HyperProver Constructor
Encode Constructor Args
MetaProver Constructor
LayerZeroProver Constructor
PolymerProver Constructor

Block Explorer API Keys

Obtaining API Keys

Get free API keys from block explorers:
1

Ethereum (Etherscan)

  1. Visit Etherscan API
  2. Create an account
  3. Generate API key
  4. Same key works for Sepolia testnet
2

Base (Basescan)

  1. Visit Basescan API
  2. Create account (separate from Etherscan)
  3. Generate API key
3

Optimism

  1. Visit Optimistic Etherscan
  2. Create account
  3. Generate API key
4

Arbitrum

  1. Visit Arbiscan
  2. Create account
  3. Generate API key

Supported Block Explorers

Verification Status

Check Verification Status

Verify a contract was successfully verified:
Successfully verified contracts will show:
  • ✅ Verified contract source code
  • Compiler version
  • Optimization settings
  • Contract ABI
  • Constructor arguments

Verification Success Indicators

In Script Output
On Block Explorer
  • Green checkmark next to contract
  • “Contract Source Code Verified” message
  • Readable source code tabs
  • Read/Write Contract interface available

Troubleshooting

Already Verified Error

If contract is already verified:
This is expected for:
  • Re-running verification script
  • Contracts deployed with same bytecode
Solution: Check block explorer to confirm verification is correct.

Invalid API Key

Solutions:
  1. Verify API key is correct in .env or verification keys file
  2. Check API key is for the correct network (Etherscan vs Basescan)
  3. Ensure API key is activated (check email for verification link)

Constructor Arguments Mismatch

Solutions:
  1. Extract constructor args from deployment CSV:
  2. Verify args match deployment transaction
  3. Check ABI encoding is correct

Rate Limiting

Solutions:
  1. Wait 5-10 seconds between verifications
  2. Use --slow flag in deployment to add delays
  3. Upgrade to premium API key for higher limits
  4. Verification script includes automatic retry with delay

Compiler Settings Mismatch

Ensure your foundry.toml matches deployment:
foundry.toml
Forge should automatically use these settings for verification.

Verification Timeout

Solutions:
  1. Increase timeout with --timeout 300 (5 minutes)
  2. Retry verification after a few minutes
  3. Check if block explorer is experiencing issues
  4. Use --watch flag to wait for completion

Contract Not Found

Solutions:
  1. Wait a few blocks for explorer to index the contract
  2. Verify contract address is correct
  3. Check transaction was successful
  4. Ensure contract was deployed on the correct network

Advanced Verification

Verify with Standard JSON Input

For complex build configurations:

Verify via Sourcify

Sourcify provides decentralized contract verification:

Multi-Chain Verification Tracking

Track verification across multiple chains:

Verification Best Practices

1

Verify Immediately After Deployment

Verify contracts as soon as deployment completes to ensure accuracy.
2

Use Automated Scripts

Use verifyRoutes.sh for consistent, repeatable verification.
3

Keep Deployment Records

Maintain deployment CSV files for verification and auditing.
4

Verify on Multiple Explorers

Verify on both Etherscan-based and Sourcify for broader coverage.
5

Document Verification Links

Share verification links with users and integrators.

Next Steps

Integration Guide

Integrate verified contracts into your application

Testing

Test deployed and verified contracts