Skip to content

debt: use the single Etherscan V2 API endpoint for unified verification / query flow w/ single API key #9196

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

Open
zerosnacks opened this issue Oct 25, 2024 · 15 comments · May be fixed by #10298
Assignees
Labels
A-internals Area: internals A-verification Area: verification T-debt Type: code debt T-feature Type: feature T-post-V1 Area: to tackle after V1
Milestone

Comments

@zerosnacks
Copy link
Member

zerosnacks commented Oct 25, 2024

Component

Other (please describe)

Describe the feature you would like

We currently have a lot of code in place to handle multichain Etherscan verification due to the different endpoints and API keys associated with each.

With the release of Etherscan V2 there is now a single unified API endpoint: https://docs.etherscan.io/etherscan-v2 accessible with a single API key

Additional context

It is currently still in beta but worth exploring

Part of this ticket would be to double check if there are no breaking changes in the V2 API

Note: it requires passing a ?chainid=n as a parameter where n is the chain id: https://docs.etherscan.io/etherscan-v2/getting-started/v2-quickstart#if-youre-coming-from-v1

@zerosnacks zerosnacks added T-feature Type: feature T-debt Type: code debt A-verification Area: verification A-internals Area: internals labels Oct 25, 2024
@github-project-automation github-project-automation bot moved this to Todo in Foundry Oct 25, 2024
@zerosnacks zerosnacks changed the title feat: update Etherscan API endpoints to use unified endpoint w/ single unified API key debt: use Etherscan V2 API endpoints to use unified endpoint w/ single unified API key Oct 25, 2024
@zerosnacks zerosnacks changed the title debt: use Etherscan V2 API endpoints to use unified endpoint w/ single unified API key debt: use the single Etherscan V2 API endpoint to unified verification / interaction flow w/ single unified API key Oct 25, 2024
@zerosnacks zerosnacks changed the title debt: use the single Etherscan V2 API endpoint to unified verification / interaction flow w/ single unified API key debt: use the single Etherscan V2 API endpoint to unified verification / query flow w/ single unified API key Oct 25, 2024
@zerosnacks zerosnacks changed the title debt: use the single Etherscan V2 API endpoint to unified verification / query flow w/ single unified API key debt: use the single Etherscan V2 API endpoint for unified verification / query flow w/ single API key Oct 28, 2024
@grandizzy grandizzy added the T-post-V1 Area: to tackle after V1 label Nov 7, 2024
@iainnash
Copy link
Contributor

Has this been started or would taking a first PR pass be helpful?

@zerosnacks
Copy link
Member Author

Hi @iainnash, this is definitely something we will want to do, just outside of the scope of our 1.0 milestone due to scope of the change (I expect we can simplify quite a lot of code and likely make breaking changes). We also have to be mindful that the Etherscan API V2 is still in beta. A first PR pass to explore this would be very useful, even if it is just a draft!

@zerosnacks
Copy link
Member Author

zerosnacks commented Dec 19, 2024

Update, diff'd against Etherscan V1, V2 removes support for - other than that all changes have been additive:

23888 (Blast Testnet)
420 (Optimism Goerli Testnet)
5 (Goerli)
59140 (Linea Goerli)

These have all been deprecated, Blast Testnet being replaced by 168587773

I think we are fine with moving ahead with the implementation

@iainnash
Copy link
Contributor

iainnash commented Dec 19, 2024 via email

@zerosnacks
Copy link
Member Author

Optimistically assigned this to you @iainnash, let me know if I misunderstood you or have any questions

@iainnash
Copy link
Contributor

iainnash commented Dec 19, 2024 via email

@iainnash
Copy link
Contributor

iainnash commented Jan 2, 2025

It seems like the best place for this to be implemented is in block-explorers unless there is a desire to move this logic into foundry core such as how sourcify is done.

@zerosnacks
Copy link
Member Author

It seems like the best place for this to be implemented is in block-explorers unless there is a desire to move this logic into foundry core such as how sourcify is done.

Changes in the verification API endpoint (e.g. .submit_contract_verification binding) should be added to block-explorers if necessary but the async flow of actually interacting with the endpoint should be part of Foundry's forge-verify crate

@iainnash
Copy link
Contributor

iainnash commented Jan 7, 2025

Submitted this PR to get the verification api endpoint updated to allow requesting with V2 endpoint.
foundry-rs/block-explorers#73

Next would be updating the forge-verify side of the code to support a new flag or adapter for V2.

@iainnash
Copy link
Contributor

Follow up here: Would be great to get the prerequisite PR foundry-rs/block-explorers#73 reviewed to start on this

mattsse added a commit to foundry-rs/block-explorers that referenced this issue Mar 15, 2025
* Fix existing verify integration tests
* Add `standard-json-input` integration tests
* Fix current single file test
* Add v2 integration tests
* Allow v2 setting on client with etherscan client

This is a prerequisite PR for
foundry-rs/foundry#9196


**Notes:**

* Fantomscan test has no env var passed in and can be removed safely.
* Gas estimates now do not fail with even 1 passed in, so skipping the
failure test because I couldn't find a failure test.

---------

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
@grandizzy
Copy link
Collaborator

Follow up here: Would be great to get the prerequisite PR foundry-rs/block-explorers#73 reviewed to start on this

@iainnash block explorers PR is now merged. thanks!

@iainnash
Copy link
Contributor

Great! Will now work on this side.

@iainnash iainnash linked a pull request Apr 14, 2025 that will close this issue
3 tasks
@iainnash
Copy link
Contributor

Here is the PR: #10298

@grandizzy grandizzy added this to the v1.2.0 milestone Apr 15, 2025
@leovigna
Copy link

leovigna commented Apr 28, 2025

Hey all, would like to share that now that Etherscan is deprecating v1, this issue is more pressing.
"To avoid service disruption, make sure to switch to API V2 by May 31, 2025. V1 API access will be disabled after this date."

@iainnash
Copy link
Contributor

Working now on adding configuration options to the yml config. Perhaps could split up the PR into 2 as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-internals Area: internals A-verification Area: verification T-debt Type: code debt T-feature Type: feature T-post-V1 Area: to tackle after V1
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants
@iainnash @leovigna @grandizzy @zerosnacks and others