0

I've successfully verified contracts on etherscan before, but this time I'm following the "Deploy with Foundry" guide on the Base docs: https://docs.base.org/guides/deploy-with-foundry/

I've successfully deployed an NFT contract, and I can see it on sepolia basescan: https://sepolia.basescan.org/address/0x0c9e26654270b305405be71c431278acdd47c6e6

The guide says that when I run the following command:

forge verify-contract 0x0c9e26654270b305405be71c431278acdd47c6e6 ./src/NFT.sol:NFT --chain 84532 --watch

I should see an output similar to this:

Start verifying contract `0x71bfCe1172A66c1c25A50b49156FAe45EB56E009` deployed on base-sepolia

Submitting verification for [src/NFT.sol:NFT] 0x71bfCe1172A66c1c25A50b49156FAe45EB56E009.
Submitted contract for verification:
        Response: `OK`
        GUID: `3i9rmtmtyyzkqpfvy7pcxj1wtgqyuybvscnq8d7ywfuskss1s7`
        URL:
        https://sepolia.basescan.org/address/0x71bfce1172a66c1c25a50b49156fae45eb56e009
Contract verification status:
Response: `NOTOK`
Details: `Pending in queue`
Contract verification status:
Response: `OK`
Details: `Pass - Verified`
Contract successfully verified

However what I'm actually getting is this:

Start verifying contract `0x0c9E26654270B305405Be71C431278acDD47C6e6` deployed on base-sepolia

Submitting verification for [src/NFT.sol:NFT] 0x0c9E26654270B305405Be71C431278acDD47C6e6.
Encountered an error verifying this contract:
Response: `NOTOK`
Details: `Invalid API Key`

Here is my .env file in my foundry project:

BASE_MAINNET_RPC="https://mainnet.base.org"
BASE_SEPOLIA_RPC="https://sepolia.base.org"
ETHERSCAN_API_KEY="<BASESCAN API KEY>"

The guide mentioned not needing an API key to verify Basescan contracts on Sepolia testnet, but I created a Basescan mainnet account and generated a key anyways just to double check. Creating this API key did not change anything.

I'm confused because (1) the guide mentions not needing an API key for Sepolia Basescan (and there's no way to actually get a key, and (2) I've tried generating a Basescan API key anyways, and (3) I know the rest of my .env file is working because I used $BASE_SEPOLIA_RPC to successfully deploy the contract.

How do I get through the NFT contract verification step on Basescan Sepolia?

2 Answers 2

0

Use the key created in Etherium Mainnet https://etherscan.io/myapikey

1
  • I have the key and I put it in my .env file! Forge should be picking that up right? It notices my rpc url in the .env file correctly. Commented Jan 11 at 20:34
0

Ah it turns out that (1) the Etherscan API Key is required, and (2) forge was not pulling the api key from the .env file successfully.

I was able to resolve the issue by adding the --etherscan-api-key flag to my forge cli command.

forge verify-contract <CONTRACT ADDRESS> ./src/NFT.sol:NFT --chain 84532 --watch --etherscan-api-key <ETHERSCAN API KEY>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.