Skip to content

chore: use Etherscan API V2 for contract verification#117

Draft
anxolin wants to merge 1 commit into
mainfrom
chore/etherscan-v2-verification
Draft

chore: use Etherscan API V2 for contract verification#117
anxolin wants to merge 1 commit into
mainfrom
chore/etherscan-v2-verification

Conversation

@anxolin

@anxolin anxolin commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

What

Adds an [etherscan] section to foundry.toml so forge verify-contract / forge script --verify use the Etherscan API V2 endpoint for all supported chains (mainnet, gnosis, sepolia, arbitrum, bnb, linea).

Why

The legacy per-explorer V1 APIs (e.g. api.gnosisscan.io) have been shut down. Verifying against them now fails with:

You are using a deprecated V1 endpoint, switch to Etherscan API V2

V2 uses a single host (api.etherscan.io/v2/api) with the chain id passed as a query parameter, and a single etherscan.io API key works across every chain. This config points each chain at the V2 endpoint so verification works out of the box.

Test plan

  1. Set a V2 key from https://etherscan.io/myapikey:
    export ETHERSCAN_API_KEY=<your etherscan.io key>
  2. Verify any already-deployed contract (example: Gnosis), now resolving via the config:
    forge verify-contract <ADDRESS> src/types/twap/TWAP.sol:TWAP \
      --chain gnosis \
      --constructor-args <ABI_ENCODED_ARGS> \
      --watch
    It should resolve the verifier URL to https://api.etherscan.io/v2/api?chainid=100 and succeed instead of returning the V1 deprecation error.
  3. Confirm the config parses:
    forge config | grep -A1 '\[etherscan'

@anxolin anxolin marked this pull request as draft June 30, 2026 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant