Skip to content

Support Etherscan API v2 #6727

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 23, 2025
Merged

Support Etherscan API v2 #6727

merged 2 commits into from
May 23, 2025

Conversation

antico5
Copy link
Contributor

@antico5 antico5 commented May 22, 2025

Closes #6716

This PR means to support the api v2 of Etherscan.io. The main difference is that with v2 you can use only one api key (from etherscan.io), to access the explorer services on all supported chains, in contrast with having to register and have multiple api keys and explorers.

There are three main scenarios in which the plugin is used right now, related to this change, and we intend to provide support for all of them.

1- The user specifies a single api key in the config. This is assumed to be an etherscan.io key and it will be used to verify contracts on all the supported chains, using the api v2.
2- The user specifies a map with network -> api key combination. This is now deprecated and we show a warning, but we still attempt to use the v1 api using these keys and endpoints until they discontinue support from Etherscan. We cannot use v2 in this case because api keys of different explorers (e.g. arbiscan) are not valid for etherscan.io v2 api.
3- The user specifies custom chains. In this case we keep the existing behavior, treating the api as an etherscan v1 api.

The actual implementation is simple, when we want to use the v2 api, we use the updated endpoint (which is etherscan.io for all chains) and pass a query parameter with the chain id.

Copy link

changeset-bot bot commented May 22, 2025

🦋 Changeset detected

Latest commit: 6b51247

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@nomicfoundation/hardhat-verify Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

"@nomicfoundation/hardhat-verify": patch
---

Support Etherscan API v2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that when we release a new hardhat version, we also add a link to the original issue issue. See here: https://github.com/NomicFoundation/hardhat/releases.
So maybe it can be added here too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, I appended the issue number to the changeset

Copy link
Contributor

@ChristopherDedominici ChristopherDedominici left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a minor comment but apart from that LGTM

@antico5 antico5 merged commit d0c3dcf into main May 23, 2025
36 checks passed
@antico5 antico5 deleted the etherscan_new_api branch May 23, 2025 08:42
@github-project-automation github-project-automation bot moved this from Backlog to Done in Hardhat May 23, 2025
@pcaversaccio
Copy link
Contributor

pcaversaccio commented May 27, 2025

3- The user specifies custom chains. In this case we keep the existing behavior, treating the api as an etherscan v1 api.

I have a question here: for the custom chains do you also show a warning? The reason I'm asking is my own (completely insane) CreateX config here with I think almost a hundred custom chains.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Support Etherscan's new API with hardhat-verify
4 participants