Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
2 tasks done
coffeexcoin opened this issue Mar 21, 2024 · 11 comments · Fixed by #9311
Closed
2 tasks done

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

coffeexcoin opened this issue Mar 21, 2024 · 11 comments · Fixed by #9311
Labels
A-config Area: config Cmd-forge-verify Command: forge verify-contract/check P-normal Priority: normal T-bug Type: bug T-to-investigate Type: to investigate
Milestone

Comments

@coffeexcoin
Copy link

Component

Forge

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

  • Foundry
  • 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 coffeexcoin added the T-bug Type: bug label Mar 21, 2024
@highskore
Copy link

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
Copy link
Member

mattsse commented Apr 9, 2024

cc @zerosnacks

@silvercondor
Copy link

silvercondor commented May 3, 2024

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
Copy link

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

@ByteWizardJ
Copy link

same error.

@rori4
Copy link

rori4 commented Jun 25, 2024

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

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

@zerosnacks zerosnacks self-assigned this Jun 25, 2024
@consentsam
Copy link

Same issue

@zerosnacks zerosnacks added Cmd-forge-verify Command: forge verify-contract/check A-config Area: config A-verification Area: verification T-to-investigate Type: to investigate and removed A-verification Area: verification labels Jul 12, 2024
@zerosnacks zerosnacks added this to the v1.0.0 milestone Jul 26, 2024
@gzliudan
Copy link

I encountered this bug also.

@zerosnacks zerosnacks added the P-high Priority: high label Jul 31, 2024
@CodeSandwich
Copy link
Contributor

CodeSandwich commented Aug 8, 2024

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.

@jenpaff jenpaff added this to Foundry Sep 30, 2024
@github-project-automation github-project-automation bot moved this to Todo in Foundry Sep 30, 2024
@borre-haechi
Copy link

Although not an ideal solution, you can make slight modifications to the Forge source code to allow the verify command to work on arbitrary chains. In my case, I modified it to support verification for the SEI chain's seitrace. You can view the changes in my pull request here:

https://github.com/borre-haechi/foundry/pull/1/files#diff-16e4f33545b1873752adc0c3470e2130266a1ef984a287800f0031fbd771ae90R270

@amusingaxl
Copy link

amusingaxl commented Oct 11, 2024

I managed to get it fixed by adding this to my foundry.toml:

[etherscan]
unknown_chain = {
    key = "${TENDERLY_ACCESS_KEY}",
    chain = 314311,
    url = "${ETH_RPC_URL}/verify/etherscan"
}

This solves the issue when verifying contracts using Tenderly Virtual Testnets. Should do the trick for other situations as well, as long as the parameters are correct.

@github-project-automation github-project-automation bot moved this from Todo to Done in Foundry Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-config Area: config Cmd-forge-verify Command: forge verify-contract/check P-normal Priority: normal T-bug Type: bug T-to-investigate Type: to investigate
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.