0

I deployed a contract on sepolia network and I would like to verify my coin using hardhat.

npx hardhat verify --network sepolia 0x44ED9AB9F4Ab72e4b1aBfEBaDf5A942617B90D18

I created an API key on blockscout

https://eth-sepolia.blockscout.com/

but when I run the verify command, I receive the error

Etherscan:
An unexpected error occurred during the verification process.
Please report this issue to the Hardhat team.
Error Details: Invalid API Key

Sourcify:
An unexpected error occurred during the verification process.
Please report this issue to the Hardhat team.
Error Details: Failed to send contract verification request.
Endpoint URL: https://sourcify.dev/server
The HTTP server response is not ok. Status code: 500 Response text: {"error":"Resource missing; unsuccessful fetching: interfaces/uniswap-v2-periphery/contracts/interfaces/IUniswapV2Router01.sol"}

Here is my hardhat.config:

require("@nomicfoundation/hardhat-toolbox");
require("@nomicfoundation/hardhat-verify");

console.log("Loading Hardhat configuration...");

module.exports = {
  solidity: "0.8.24",
  networks: {
    sepolia: {
      url: "my_url_censored",
      accounts: ["my_priv_key"]
    }
  },
  etherscan: {
    apiKey: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
  },
  sourcify: {
    enabled: true
  }
};

1 Answer 1

1

By default, hardhat verifies the contract on the corresponding network's Etherscan explorer, i.e., Sepolia-Etherscan in this case. Since, the API key that you're using belongs to Blockscout explorer, therefore it's getting invalidated as it's trying to verify the contract on Sepolia-Etherscan.

For verification using Blockscout API key on Blockscout explorer, you need to mention the network configurations (including network, chainId, apiUrl, browserUrl) in the customChains array of the etherscan object in your hardhat.config.js.

So, your hardhat.config.js should look like this:

require("@nomicfoundation/hardhat-toolbox");
require("@nomicfoundation/hardhat-verify");

console.log("Loading Hardhat configuration...");

module.exports = {
  solidity: "0.8.24",
  networks: {
    sepolia: {
      url: "my_url_censored",
      accounts: ["my_priv_key"]
    }
  },
  etherscan: {
    apiKey: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    customChains: [
      {
        network: "sepolia",
        chainId: 11155111,
        urls: {
          apiURL: "https://eth-sepolia.blockscout.com/api",
          browserURL: "https://eth-sepolia.blockscout.com"
        },
      }
    ]
  },
  sourcify: {
    enabled: true
  }
};

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.