Skip to content

Etherscan V2 API migration #7623

Description

@rosahadi

Version of Hardhat

3

What happened?

I'm using Hardhat v3 with @nomicfoundation/hardhat-verify and trying to verify a contract on Sepolia.
When I call my verify script, I get this error:

HardhatError: HHE80023: The contract verification request failed:
"You are using a deprecated V1 endpoint, switch to Etherscan API V2 using https://docs.etherscan.io/v2-migration"

Root Cause

In packages/hardhat-verify/src/internal/etherscan.ts line 60, the constructor has:

this.apiUrl = etherscanConfig.apiUrl ?? ETHERSCAN_API_URL;

The ETHERSCAN_API_URL constant is already set to the V2 endpoint (https://api.etherscan.io/v2/api), but when etherscanConfig.apiUrl is provided (possibly from old chain configs), it uses the deprecated V1 endpoint instead.

Fix

I removed the fallback to etherscanConfig.apiUrl to always use the V2 constant:

this.apiUrl = ETHERSCAN_API_URL;

Tested locally and verification now works

Minimal reproduction steps

  1. Install Hardhat v3 with @nomicfoundation/hardhat-verify
  2. Configure Etherscan verification with a V2 API key
  3. Try to verify a contract on Sepolia
  4. The verification fails with the V1 endpoint deprecation error

Search terms

No response

Metadata

Metadata

Assignees

Labels

Type

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions