foundry
foundry copied to clipboard
forge verify-contract error when using --chain parameter
Component
Forge
Have you ensured that all of these are up to date?
- [X] Foundry
- [X] Foundryup
What version of Foundry are you on?
forge 0.2.0 (e5318c3 2024-03-21T00:17:26.798143000Z)
What command(s) is the bug in?
forge verify-contract
Operating System
macOS (Apple Silicon)
Describe the bug
Using forge verify-contract
or forge create --verify
with an alternate chain ID always fails with "ETHERSCAN_API_KEY must be set"
The ETHERSCAN_API_KEY
environment variable is already set in my environment. There are no customizations to foundry.toml.
forge verify-contract --etherscan-api-key $ETHERSCAN_API_KEY --rpc-url $RPC_URL --verifier-url $VERIFIER_URL --chain 2 $CONTRACT x.sol:X
Start verifying contract `0x85E8697e8Be8B807A423af0aa812cfA4a1682a84 ` deployed on morden
Error:
ETHERSCAN_API_KEY must be set
Have the same issue, my error is Missing etherscan key for chain 123456789
using
forge script script/Deploy_Create.s.sol:Deploy --rpc-url $RPC_URL \
-vv \
--broadcast \
--chain 123456789 \
--slow \
--verify \
--verifier-url ${VERIFIERY_URL} \
--etherscan-api-key ${KEY}
forge 0.2.0 (72bc4f4 2024-04-08T00:17:17.438514000Z)
cc @zerosnacks
getting the same error.
setting env var or passing -e
--etherscan-api-key
doesn't work either
forge 0.2.0 (d495216 2024-05-03T00:18:57.034339671Z)
The same issue applies when using a Tenderly Testnet with custom chain ID.
same error.
I can also confirm that this is an issue with latest forge
forge 0.2.0 (ba9fa20 2024-06-24T00:23:20.410766000Z)
Same issue
I encountered this bug also.
I got hit by that too, but from a different angle. I'm getting ETHERSCAN_API_KEY must be set
despite not using --chain
in any form. It seems that having ETH_RPC_URL
set makes Foundry fetch the chain ID, probably from the RPC server, and that's enough to trigger this bug. Not passing any RPC URL to Foundry solves the issue for me.