foundry: Can not verify deployed contract

Component

Forge

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

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.1.0 (2ff2b33 2022-03-06T00:10:54.403068+00:00)

What command(s) is the bug in?

forge verify-contract

Operating System

macOS (amd)

Describe the bug

The code of contract is here: https://github.com/piavgh/simple-ens-foundry

I deployed the contract using this command:

forge create --rpc-url https://eth-ropsten.alchemyapi.io/v2/<alchemy-key> --constructor-args "geek" --private-key <my-private-key> src/Domains.sol:Domains

Then I verified it with

forge verify-contract --chain-id 3 --num-of-optimizations 200 --constructor-args 0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000046765656b00000000000000000000000000000000000000000000000000000000 --compiler-version v0.8.10+commit.fc410830 0x19f4cd4bc239b8c32f264bf13efbe31a0fc4194d src/Domains.sol:Domains <my-etherscan-api-key>

I tried with different values of --num-of-optimizations: 0, 200 (default), 1000000, and even skip this argument, but all of them give the same value when I tried the forge verify-check:

Error:
   0: Contract verification failed:
      Response: `NOTOK`
      Details: `Fail - Unable to verify`

Location:
   cli/src/cmd/verify.rs:126

Backtrace omitted.
Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 3
  • Comments: 21 (9 by maintainers)

Most upvoted comments

I believe the root of the problem is the Etherscan API Key

An API request with Invalid API Key:
{"status":"0","message":"NOTOK","result":"Invalid API Key"}

source: https://info.etherscan.com/api-return-errors/

However I am having the same issue despite attempting to verify with multiple API Keys and via the Etherscan website, too.

The problem may have to do with using unversioned OpenZeppelin imports in the contract. See here https://forum.openzeppelin.com/t/how-to-verify-a-contract-on-etherscan-bscscan-polygonscan/14225#use-versioned-imports-in-remix-10

I don’t think so. I use the same key but I was able to verify contract with hardhat