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:- 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
Configure Verification Keys
Create verification keys file or set environment variable:Option 1: JSON FileOption 2: Environment Variable
verification-keys.json
Verification Script Features
Automatic Header Removal- Detects and removes CSV headers before processing
- Retries failed verifications with 5-second delay
- Useful for rate limiting or temporary explorer issues
- Uses chain data for more reliable verification
- Falls back to explorer defaults if not available
- Shows verification progress (e.g., “2 of 5”)
- Provides summary statistics at end
- 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
| Flag | Description |
|---|---|
--chain | Network name or chain ID (e.g., mainnet, 1, sepolia, 11155111) |
--etherscan-api-key | API key for block explorer |
--constructor-args | ABI-encoded constructor arguments |
--watch | Wait for verification to complete |
--rpc-url | Custom RPC endpoint for the chain |
Constructor Arguments
For contracts with constructor parameters, you need to provide ABI-encoded arguments. HyperProver ConstructorBlock Explorer API Keys
Obtaining API Keys
Get free API keys from block explorers:Ethereum (Etherscan)
- Visit Etherscan API
- Create an account
- Generate API key
- Same key works for Sepolia testnet
Base (Basescan)
- Visit Basescan API
- Create account (separate from Etherscan)
- Generate API key
Optimism
- Visit Optimistic Etherscan
- Create account
- Generate API key
Arbitrum
- Visit Arbiscan
- Create account
- Generate API key
Supported Block Explorers
| Chain | Explorer | API Documentation |
|---|---|---|
| Ethereum | Etherscan | https://etherscan.io/apis |
| Base | Basescan | https://basescan.org/apis |
| Optimism | Optimistic Etherscan | https://optimistic.etherscan.io/apis |
| Arbitrum | Arbiscan | https://arbiscan.io/apis |
| Polygon | Polygonscan | https://polygonscan.com/apis |
| BSC | BscScan | https://bscscan.com/apis |
| Avalanche | Snowtrace | https://snowtrace.io/apis |
Verification Status
Check Verification Status
Verify a contract was successfully verified:- ✅ Verified contract source code
- Compiler version
- Optimization settings
- Contract ABI
- Constructor arguments
Verification Success Indicators
In Script Output- 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:- Re-running verification script
- Contracts deployed with same bytecode
Invalid API Key
- Verify API key is correct in
.envor verification keys file - Check API key is for the correct network (Etherscan vs Basescan)
- Ensure API key is activated (check email for verification link)
Constructor Arguments Mismatch
- Extract constructor args from deployment CSV:
- Verify args match deployment transaction
- Check ABI encoding is correct
Rate Limiting
- Wait 5-10 seconds between verifications
- Use
--slowflag in deployment to add delays - Upgrade to premium API key for higher limits
- Verification script includes automatic retry with delay
Compiler Settings Mismatch
foundry.toml matches deployment:
foundry.toml
Verification Timeout
- Increase timeout with
--timeout 300(5 minutes) - Retry verification after a few minutes
- Check if block explorer is experiencing issues
- Use
--watchflag to wait for completion
Contract Not Found
- Wait a few blocks for explorer to index the contract
- Verify contract address is correct
- Check transaction was successful
- 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
Verify Immediately After Deployment
Verify contracts as soon as deployment completes to ensure accuracy.
Next Steps
Integration Guide
Integrate verified contracts into your application
Testing
Test deployed and verified contracts