diff --git a/contracts/README.md b/contracts/README.md index 6275c98214..ab816130c9 100644 --- a/contracts/README.md +++ b/contracts/README.md @@ -419,7 +419,7 @@ Validator public key: 90db8ae56a9e741775ca37dd960606541306974d4a998ef6a6227c85a9 ## Contract Verification -The Hardhat plug-in [@nomiclabs/hardhat-etherscan](https://www.npmjs.com/package/@nomiclabs/hardhat-etherscan) is used to verify contracts on Etherscan. +The Hardhat plug-in [@nomiclabs/hardhat-verify](https://www.npmjs.com/package/@nomiclabs/hardhat-etherscan) is used to verify contracts on Etherscan. Etherscan has migrated to V2 api where all the chains use the same endpoint. There's an example @@ -427,6 +427,27 @@ There's an example npx hardhat --network mainnet verify --contract contracts/vault/VaultAdmin.sol:VaultAdmin 0x31a91336414d3B955E494E7d485a6B06b55FC8fB ``` +`hardhat-deploy` package offers a secondary way to verify contracts, where contructor parameters don't need to be passed into the verification call. Since Etherscan has migrated to V2 api this approach is no longer working. `etherscan-verify` call uses `hardhat verify` under the hood. +``` +npx hardhat etherscan-verify --network mainnet --api-url https://api.etherscan.io +``` + +#### Addressing verification slowdowns + +Profiling the `hardhat-verify` prooved that when the `hardhat verify` is ran without --contract parameter +it can take up to 4-5 minutes to gather the necessary contract information. +Use `--contract` e.g. `--contract contracts/vault/VaultAdmin.sol:VaultAdmin` to mitigate the issue. + +#### Migration to full support of Etherscan V2 api + +Migrating to Etherscan V2 has been attempted with no success. +Resources: + - migration guid by Etherscan: https://docs.etherscan.io/v2-migration + - guide for Hardhat setup: https://docs.etherscan.io/contract-verification/verify-with-hardhat. (note upgrading @nomicfoundation/hardhat-verify to 2.0.14 didn't resolve the issue last time) + - openzeppelin-upgrades claims to have solved the issue in 3.9.1 version of the package: https://github.com/OpenZeppelin/openzeppelin-upgrades/issues/1165 Not only does this not solve the verification issue, it is also a breaking change for our repo. + +Good luck when attempting to solve this. + ### Deployed contract code verification To verify the deployed contract against the locally compiled contracts sol2uml from Nick Addison is convenient: diff --git a/contracts/hardhat.config.js b/contracts/hardhat.config.js index 0c2574704f..6822cd9ce0 100644 --- a/contracts/hardhat.config.js +++ b/contracts/hardhat.config.js @@ -415,19 +415,27 @@ module.exports = { etherscan: { apiKey: { mainnet: process.env.ETHERSCAN_API_KEY, - arbitrumOne: process.env.ARBISCAN_API_KEY, + arbitrumOne: process.env.ETHERSCAN_API_KEY, holesky: process.env.ETHERSCAN_API_KEY, - base: process.env.BASESCAN_API_KEY, - sonic: process.env.SONICSCAN_API_KEY, - hoodi: process.env.HOODISCAN_API_KEY, + base: process.env.ETHERSCAN_API_KEY, + sonic: process.env.ETHERSCAN_API_KEY, + hoodi: process.env.ETHERSCAN_API_KEY, plume: "empty", // this works for: npx hardhat verify... }, customChains: [ + { + network: "mainnet", + chainId: 1, + urls: { + apiURL: "https://api.etherscan.io/v2/api?chainId=1", + browserURL: "https://etherscan.io", + }, + }, { network: "holesky", chainId: 17000, urls: { - apiURL: "https://api-holesky.etherscan.io/api", + apiURL: "https://api.etherscan.io/v2/api?chainId=17000", browserURL: "https://holesky.etherscan.io", }, }, @@ -435,7 +443,7 @@ module.exports = { network: "base", chainId: 8453, urls: { - apiURL: "https://api.basescan.org/api", + apiURL: "https://api.etherscan.io/v2/api?chainId=8453", browserURL: "https://basescan.org", }, }, @@ -443,7 +451,7 @@ module.exports = { network: "sonic", chainId: 146, urls: { - apiURL: "https://api.sonicscan.org/api", + apiURL: "https://api.etherscan.io/v2/api?chainId=146", browserURL: "https://sonicscan.org", }, }, @@ -459,7 +467,7 @@ module.exports = { network: "hoodi", chainId: 560048, urls: { - apiURL: "https://hoodi.etherscan.io/api", + apiURL: "https://api.etherscan.io/v2/api?chainId=560048", browserURL: "https://hoodi.etherscan.io", }, },