foundry icon indicating copy to clipboard operation
foundry copied to clipboard

forge verify-contract returns invalid API Key despite forge script --verify working fine

Open jordaniza opened this issue 3 years ago • 6 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 (ccb9aa5 2022-08-17T00:03:47.513943128Z)

What command(s) is the bug in?

forge verify-contract

Operating System

Linux

Describe the bug

I've mentioned a couple of other, smaller issues with the foundry verification process. This one is a bit more frustrating.

In general, I've found that adding --verify to my foundry scripts is an awesome way to keep my contracts verified with little effort. I also have a handy --resume flag to attempt re-verifications if network conditions are poor.

forge-verify however, I have had extremely mixed results. I am able to deploy, then subsequently verify, very simple contracts (ones without imports or libraries), but then real-world contracts frequently fail.

Specifically, verification is accepted, but verify-check returns a NOTOK status with Invalid API Key.

This behaviour has been replicated on several testnets:

Arbitrum Rinkeby Optiism Kovan Fantom Testnet Polygon Mumbai Avalance Fuji

The combination of --verify working in forge script, but verify-contract often not working (but working for less complex contracts) leads me to believe this is a challenge within foundry.

I am happy to provide more details and, privately, share some of the contracts with the team to investigate if needed.

jordaniza avatar Aug 17 '22 07:08 jordaniza

@jordaniza would appreciate the invite to sample repo

rkrasiuk avatar Aug 17 '22 12:08 rkrasiuk

Being an Invalid API Key, it leads me to believe that you're somehow calling it with wrong API Keys or with wrong chain ids.

For example, avalanche/fuji key != ethereum/mainnet/goerli keys.

For verify-check you still have to call it with the correct --chain-id and --etherscan-key, it's not enough to do forge vc GUID.

joshieDo avatar Aug 17 '22 12:08 joshieDo

Appreciate the pointers, we'll aware of the chain id and key config settings. Verify works fine if passed after forge script, so the etherscan api key is not the problem.

Chain ID I definitely pass, I will share the bash scripts when putting up the other sample repo for the other issue.

jordaniza avatar Aug 17 '22 12:08 jordaniza

@jordaniza hey, could you give an update on this issue? if it persists - could you pls provide a minimal reproducible example?

rkrasiuk avatar Sep 17 '22 14:09 rkrasiuk

my bad @rkrasiuk this totally slipped my mind.

I've in general stopped using forge-verify because I have basically had full success deploying with forge script --verify and using --resume if etherscan hasn't caught up.

I will try verifying contracts on the latest version of foundry and see if my old issues persist!

jordaniza avatar Sep 19 '22 11:09 jordaniza

@jordaniza thanks for getting back, will wait for the result

rkrasiuk avatar Sep 19 '22 13:09 rkrasiuk

Closing as stale—we've improved verification a bit since

Evalir avatar Jun 20 '23 18:06 Evalir