foundry-rs / foundry

Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.
https://getfoundry.sh
Apache License 2.0
8.03k stars 1.64k forks source link

forge verify-contract error when using --chain parameter #7466

Open coffeexcoin opened 5 months ago

coffeexcoin commented 5 months ago

Component

Forge

Have you ensured that all of these are up to date?

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
highskore commented 4 months ago

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)

mattsse commented 4 months ago

cc @zerosnacks

silvercondor commented 3 months ago

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)

amusingaxl commented 3 months ago

The same issue applies when using a Tenderly Testnet with custom chain ID.

cryptochou commented 1 month ago

same error.

rori4 commented 1 month ago

I can also confirm that this is an issue with latest forge

forge 0.2.0 (ba9fa20 2024-06-24T00:23:20.410766000Z)
consentsam commented 1 month ago

Same issue

gzliudan commented 3 weeks ago

I encountered this bug also.

CodeSandwich commented 2 weeks ago

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.