diff --git a/contracts/README.md b/contracts/README.md index 6275c98214..029cd8a612 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. Hardhat verify should be run with `--contract` parameter otherwise there is a significant slowdown while hardhat is gathering contract information. There's an example @@ -427,6 +427,43 @@ There's an example npx hardhat --network mainnet verify --contract contracts/vault/VaultAdmin.sol:VaultAdmin 0x31a91336414d3B955E494E7d485a6B06b55FC8fB ``` +Example with constructor parameters passed as command params +``` +yarn hardhat verify --network mainnet 0x0FC66355B681503eFeE7741BD848080d809FD6db --contract contracts/poolBooster/PoolBoosterFactoryMerkl.sol:PoolBoosterFactoryMerkl 0x856c4Efb76C1D1AE02e20CEB03A2A6a08b0b8dC3 0x4FF1b9D9ba8558F5EAfCec096318eA0d8b541971 0xAA8af8Db4B6a827B51786334d26349eb03569731 0x8BB4C975Ff3c250e0ceEA271728547f3802B36Fd +``` + +Example with constructor parameters saved to file and file path passed to the command +``` +echo "module.exports = [{ + platformAddress: \"0x0000000000000000000000000000000000000001\", + vaultAddress: \"0xe75d77b1865ae93c7eaa3040b038d7aa7bc02f70\", +}]" > flux-args.js +npx hardhat --network mainnet verify --contract contracts/strategies/FluxStrategy.sol:FluxStrategy --constructor-args flux-args.js 0x57d49c28Cf9A0f65B1279a97eD01C3e49a5A173f +``` + + + +`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", }, },