Prerequisites
Before verifying contracts, ensure you have:- Node.js and yarn installed
- Cloned the CoW Protocol contracts repository
- Deployed contracts on your target network
- Appropriate API keys for verification services
Etherscan Verification
Etherscan verification works for all Etherscan-based block explorers including:- Etherscan (Ethereum)
- Gnosisscan (Gnosis Chain)
- Arbiscan (Arbitrum)
- Optimistic Etherscan (Optimism)
- PolygonScan (Polygon)
- BscScan (BSC)
- BaseScan (Base)
- SnowTrace (Avalanche)
Setup API Key
First, obtain an API key from the relevant block explorer and set it as an environment variable:Most Etherscan-based explorers use the same API key variable
ETHERSCAN_API_KEY. Check your Hardhat configuration for network-specific variable names.Verify All Deployed Contracts
To verify all contracts deployed on a specific network:Supported Network Names
Supported Network Names
The following network names are recognized by the verification scripts:
mainnet- Ethereum Mainnetxdai- Gnosis ChainarbitrumOne- Arbitrum Oneoptimism- Optimismpolygon- Polygonbsc- BNB Smart Chainbase- Baseavalanche- Avalanche C-Chainsepolia- Sepolia Testnetgoerli- Goerli Testnet (deprecated)rinkeby- Rinkeby Testnet (deprecated)
Verify Individual Contracts
Some contracts, like the VaultRelayer, are deployed indirectly and require manual verification with constructor arguments.Verify GPv2VaultRelayer
The VaultRelayer contract requires the Balancer Vault address as a constructor argument:The Balancer Vault address (
0xBA12222222228d8Ba445958a75a0704d566BF2C8) is consistent across most networks.Verify Custom Contracts
For other contracts with constructor arguments:Verification Example
Complete example for Ethereum mainnet:Tenderly Verification
Tenderly provides advanced debugging and monitoring capabilities. Verify contracts on Tenderly for enhanced development experience.Setup Tenderly
First, configure Tenderly credentials:Verify All Contracts
Verify all deployed contracts on a network:Verify Individual Contract
Verify a specific contract by name and address:Common Contract Names
Common Contract Names
Use these contract names when verifying on Tenderly:
GPv2SettlementGPv2AllowListAuthenticationGPv2VaultRelayerGPv2AllowListAuthentication_ImplementationGPv2AllowListAuthentication_Proxy
Verify Multiple Contracts
You can verify multiple contracts in a single command:Verification Best Practices
Verification Checklist
Before considering verification complete:- All core contracts verified on primary block explorer
- VaultRelayer contract manually verified with correct constructor args
- Proxy and implementation contracts both verified
- Contract source code matches repository
- Compiler version and settings are correct
- Constructor arguments are properly encoded
- Verification status visible on block explorer
Troubleshooting
Common Issues
Error: Already Verified
Error: Already Verified
If a contract is already verified, you’ll see an error message. This is normal and means the contract is already accessible on the block explorer.No action needed - the contract is already verified.
Error: Constructor Arguments
Error: Constructor Arguments
If verification fails due to constructor arguments:Solution:
- Find the deployment transaction on the block explorer
- Extract constructor arguments from the transaction input data
- Provide them explicitly to the verify command
Error: Invalid API Key
Error: Invalid API Key
If you see an API key error:Solution:
- Verify your API key is correct
- Ensure environment variable is properly set
- Check API key has not expired
- Confirm API key is for the correct network
Error: Network Not Supported
Error: Network Not Supported
If the network is not recognized:Solution:
- Check
hardhat.config.tsfor supported networks - Ensure network name matches configuration
- Verify RPC URL is accessible
- Check network is supported by the block explorer
