Repository navigation
forge verify-contract failing on Basescan even though constructor args look correct #16999
|
Deployed a contract to Base via Keeps failing with "Unable to verify" but no specific error. The contract definitely deployed successfully and works fine. Things I've tried:
Is Basescan just flaky or am I encoding the constructor args wrong? The same flow worked fine on Ethereum mainnet last month. |
Replies: 1 comment
|
This one almost always comes down to constructor args encoding or compiler metadata, not Basescan being flaky. A few things to check in order of likelihood: 1. Constructor args encoding — cast abi-encode "f(address,string,string,address)" 0xUSDC... "Vault" "vTKN" 0xFEE...The function name doesn't matter (Foundry ignores it), but 2. Metadata hash mismatch — even if the optimizer settings match, Solidity appends a CBOR-encoded metadata hash at the end of the bytecode. If anything differs between your local compilation and what you deployed (different file path, different solc binary, different OS), the hash won't match. Try adding 3. Basescan API key — you need one. Without it, Basescan rate-limits you silently and returns generic errors. Get one from basescan.org (free tier is fine). 4. Try The fact that it worked on Ethereum mainnet but not Base suggests the compiler metadata hash — you might have recompiled between deploys. |
This one almost always comes down to constructor args encoding or compiler metadata, not Basescan being flaky.
A few things to check in order of likelihood:
1. Constructor args encoding —
cast abi-encodewith the wordconstructorin the signature is wrong. Drop it:The function name doesn't matter (Foundry ignores it), but
constructor(...)can trip up some versions. If you want to be safe, just pass the raw hex directly with--constructor-args-path.2. Metadata hash mismatch — even if the optimizer settings match, Solidity appends a CBOR-encoded metadata hash at the end of the bytecode. If anything differ…