hardhat icon indicating copy to clipboard operation
hardhat copied to clipboard

Add support for generic block explorers

Open schaable opened this issue 5 months ago • 11 comments

Describe the feature

Originally requested in #6905.

We should add support for generic block explorers that implement the Etherscan v1 API, optionally using an API key. The explorer mentioned in the original request is Oklink, but there may be others as well. A brief investigation is recommended to identify and prioritize the most relevant ones for support.

Search terms

No response

schaable avatar Jun 30 '25 16:06 schaable

Hi, blockscout-based explorers also need it

ericlee42 avatar Jul 02 '25 04:07 ericlee42

Hi @ericlee42, Blockscout-based explorers should already work, as the plugin supports them. Is there a specific scenario that isn’t working as expected?

schaable avatar Jul 02 '25 13:07 schaable

@schaable I've gotten the solution.

  etherscan: {
    enabled: false,
  },
  blockscout: {
    enabled: true,

But it's not handy, I have to set etherscan.enabled to false to use blockscout mode.

Can you team add a flag for them, e.g. hardhat verify --blockscout or hardhat verify —verifier=blockscout

ericlee42 avatar Jul 02 '25 13:07 ericlee42

Another example is routescan.io that implements the Etherscan API, without a key

kuzdogan avatar Jul 08 '25 10:07 kuzdogan

Hi @ericlee42, Blockscout-based explorers should already work, as the plugin supports them. Is there a specific scenario that isn’t working as expected?

I am validating in blockscout with customChains. I also specify a dummy apiKey value. My config worked until I upgraded to Hardhat v2.2.5.0 from 2.24.3. Now I get this warning when I verify:

[WARNING] Network and explorer-specific api keys are deprecated in favour of the new Etherscan v2 api. Support for v1 is expected to end by May 31st, 2025. To migrate, please specify a single Etherscan.io api key the apiKey config value.

The verification is successful, but the warning is a bit ugly and confusing. Is there any way to get rid of this warning when verifying in blockscout?

hswopeams avatar Jul 08 '25 10:07 hswopeams

@schaable I've gotten the solution.

  etherscan: {
    enabled: false,
  },
  blockscout: {
    enabled: true,

But it's not handy, I have to set etherscan.enabled to false to use blockscout mode.

Can you team add a flag for them, e.g. hardhat verify --blockscout or hardhat verify —verifier=blockscout

Where does this go in your hardhat config? Do you have an example?

hswopeams avatar Jul 08 '25 10:07 hswopeams

@schaable I've gotten the solution.

  etherscan: {
    enabled: false,
  },
  blockscout: {
    enabled: true,

But it's not handy, I have to set etherscan.enabled to false to use blockscout mode. Can you team add a flag for them, e.g. hardhat verify --blockscout or hardhat verify —verifier=blockscout

Where does this go in your hardhat config? Do you have an example?

This is the config for the Hardhat 3 Alpha.

Have you updated to the latest version of hardhat-verify it added support for Etherscan API v2: https://github.com/NomicFoundation/hardhat/releases/tag/%40nomicfoundation%2Fhardhat-verify%402.0.14

kanej avatar Jul 08 '25 10:07 kanej

@schaable I've gotten the solution.

  etherscan: {
    enabled: false,
  },
  blockscout: {
    enabled: true,

But it's not handy, I have to set etherscan.enabled to false to use blockscout mode. Can you team add a flag for them, e.g. hardhat verify --blockscout or hardhat verify —verifier=blockscout

Where does this go in your hardhat config? Do you have an example?

This is the config for the Hardhat 3 Alpha.

Have you updated to the latest version of hardhat-verify it added support for Etherscan API v2: https://github.com/NomicFoundation/hardhat/releases/tag/%40nomicfoundation%2Fhardhat-verify%402.0.14

I'm not on V3, so I guess that config won't fork. I'm on v2.2.5.0. That is the latest version of V2 with latest versions of all @nomicfoundation/hardhat-toolbox plugins. To try to solve the warning issue, I have created a brand new v2.25.0 project.

But I'm verifying against blockscout, not Etherscan. I just want to do that without this warning.

hswopeams avatar Jul 08 '25 10:07 hswopeams

@schaable I've gotten the solution.

  etherscan: {
    enabled: false,
  },
  blockscout: {
    enabled: true,

But it's not handy, I have to set etherscan.enabled to false to use blockscout mode.

Can you team add a flag for them, e.g. hardhat verify --blockscout or hardhat verify —verifier=blockscout

You definitely don't need to do that in v3: npx hardhat verify blockscout ... should do the trick.

schaable avatar Jul 08 '25 15:07 schaable

Resolved by Hardhat 3

michalbrabec avatar Aug 21 '25 13:08 michalbrabec

PSA: @nomicfoundation/[email protected] now works out of the box with all the chains officially supported by Etherscan, Blockscout, and Sourcify.

alcuadrado avatar Nov 12 '25 20:11 alcuadrado