Skip to content

"Invalid API Key" with Etherscan for forge clone on BNB Smart Chain on Foundry docker. #9857

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

Closed
2 tasks done
alandixon opened this issue Feb 11, 2025 · 3 comments
Closed
2 tasks done
Labels
T-bug Type: bug T-needs-triage Type: this issue needs to be labelled

Comments

@alandixon
Copy link

Component

Forge

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

  • Foundry
  • Foundryup

What version of Foundry are you on?

0.3.1-dev 2025-01-21T16:48:49

What version of Foundryup are you on?

N/A - Docker

What command(s) is the bug in?

forge clone

Operating System

Windows

Describe the bug

Using foundry on docker.

Trying to get forge clone to retrieve contract source code.

forge clone works OK on ETH mainnet (chain_id=1):
forge clone --no-git --no-commit --etherscan-api-key {api_key} --chain 1 0x3554A54BC0F1f3aDABa5E3a4CcB35E84418bF553

but fails on BSC (chain_id=56):
forge clone --no-git --no-commit --etherscan-api-key {api_key} --chain 56 0x55aBdae5B1b94a203362c49be12550e77D73171e
with
Error: Invalid API Key


curl works OK in both cases, so I know the contracts, the chain_id and the api_key are all good:

ETH mainnet:
curl -d "address=0x3554A54BC0F1f3aDABa5E3a4CcB35E84418bF553" "https://api.etherscan.io/v2/api?chainid=1&module=contract&action=getsourcecode&apikey={apikey}"

BSC:
curl -d "address=0x55aBdae5B1b94a203362c49be12550e77D73171e" "https://api.etherscan.io/v2/api?chainid=56&module=contract&action=getsourcecode&apikey={apikey}"

@alandixon alandixon added T-bug Type: bug T-needs-triage Type: this issue needs to be labelled labels Feb 11, 2025
@github-project-automation github-project-automation bot moved this to Todo in Foundry Feb 11, 2025
@grandizzy
Copy link
Collaborator

@alandixon we currently don't support the v2 API (looking to add in #9196) please try using a v1 bsc api key

@grandizzy
Copy link
Collaborator

@alandixon please reopen if you still hit the issue with a v1 bsc api key. will close this a dupe of #9196 Thank you!

@github-project-automation github-project-automation bot moved this from Todo to Done in Foundry Feb 11, 2025
@alandixon
Copy link
Author

Actually, curl doesn't even work on api v1, using bscscan example code, so it looks like a bscscan problem.
I'll probably look at using v2 when #9196 is complete,
and work round it for the time being.
Thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-bug Type: bug T-needs-triage Type: this issue needs to be labelled
Projects
Status: Done
Development

No branches or pull requests

2 participants