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
- Install Hardhat v3 with @nomicfoundation/hardhat-verify
- Configure Etherscan verification with a V2 API key
- Try to verify a contract on Sepolia
- The verification fails with the V1 endpoint deprecation error
Search terms
No response
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:
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
Search terms
No response