Automatic Verification
The easiest way to verify contracts is during deployment by adding the--verify flag to your Forge script command.
During Deployment
Ensure the
ETHERSCAN_API_KEY environment variable is set before using the --verify flag.Manual Verification
If automatic verification fails or you need to verify an already deployed contract, use theforge verify-contract command.
Prerequisites
Verify FlashLoanRouter
The FlashLoanRouter is initialized with the CoW Settlement contract address (0x9008D19f58AAbD9eD0D60971565AA8510560ab41).
The constructor argument is the CoW Settlement contract address, which is consistent across all supported networks.
Verify AaveBorrower
The AaveBorrower is initialized with the FlashLoanRouter address.Verify ERC3156Borrower
The ERC3156Borrower is also initialized with the FlashLoanRouter address.Understanding Constructor Arguments
Thecast abi-encode command encodes constructor arguments in the format expected by Etherscan.
Syntax
Examples
Network-Specific API Keys
Different networks require different API keys:| Network | Explorer | API Key Environment Variable |
|---|---|---|
| Ethereum | Etherscan | ETHERSCAN_API_KEY |
| Polygon | Polygonscan | POLYGONSCAN_API_KEY |
| Arbitrum | Arbiscan | ARBISCAN_API_KEY |
| Optimism | Optimistic Etherscan | OPTIMISM_API_KEY |
| Base | Basescan | BASESCAN_API_KEY |
| BSC | BscScan | BSCSCAN_API_KEY |
| Avalanche | Snowtrace | SNOWTRACE_API_KEY |
| Gnosis | Gnosisscan | GNOSISSCAN_API_KEY |
| Linea | Lineascan | LINEASCAN_API_KEY |
Verification Status
After running the verification command, you’ll see one of these outputs:Success
Success
Already Verified
Already Verified
Failed
Failed
- Incorrect constructor arguments
- Wrong compiler version or settings
- Invalid API key
- Network issues
Troubleshooting
Constructor argument mismatch
Constructor argument mismatch
Ensure you’re using the correct addresses for constructor arguments:
- FlashLoanRouter: Uses CoW Settlement address
0x9008D19f58AAbD9eD0D60971565AA8510560ab41 - Borrower contracts: Use FlashLoanRouter address
0x9da8B48441583a2b93e2eF8213aAD0EC0b392C69
networks.json for the specific network.Compiler version mismatch
Compiler version mismatch
The contracts are compiled with specific settings from Forge automatically uses these settings during verification.
foundry.toml:Rate limiting
Rate limiting
Block explorer APIs have rate limits. If you encounter rate limiting:
- Wait a few minutes before retrying
- Verify contracts sequentially, not in parallel
- Check your API key tier for rate limit details
Invalid API key
Invalid API key
Verify your API key is:
- Correctly set in environment variables
- Valid and not expired
- For the correct network (e.g., mainnet vs testnet)
- Has verification permissions enabled