foundry icon indicating copy to clipboard operation
foundry copied to clipboard

forge verify-contract error when using --chain parameter

Open coffeexcoin opened this issue 11 months ago • 9 comments

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

coffeexcoin avatar Mar 21 '24 19:03 coffeexcoin

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)

highskore avatar Apr 08 '24 15:04 highskore

cc @zerosnacks

mattsse avatar Apr 09 '24 12:04 mattsse

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)

silvercondor avatar May 03 '24 09:05 silvercondor

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

amusingaxl avatar May 21 '24 14:05 amusingaxl

same error.

cryptochou avatar Jun 25 '24 02:06 cryptochou

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

forge 0.2.0 (ba9fa20 2024-06-24T00:23:20.410766000Z)

rori4 avatar Jun 25 '24 08:06 rori4

Same issue

consentsam avatar Jul 01 '24 06:07 consentsam

I encountered this bug also.

gzliudan avatar Jul 31 '24 10:07 gzliudan

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.

CodeSandwich avatar Aug 08 '24 17:08 CodeSandwich