Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -419,14 +419,35 @@ 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

```
npx hardhat --network mainnet verify --contract contracts/vault/VaultAdmin.sol:VaultAdmin 0x31a91336414d3B955E494E7d485a6B06b55FC8fB
```

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add an example with a constructor parameter. This one is from the deployment template in Notion

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:
Expand Down
24 changes: 16 additions & 8 deletions contracts/hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,35 +415,43 @@ 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",
},
},
{
network: "base",
chainId: 8453,
urls: {
apiURL: "https://api.basescan.org/api",
apiURL: "https://api.etherscan.io/v2/api?chainId=8453",
browserURL: "https://basescan.org",
},
},
{
network: "sonic",
chainId: 146,
urls: {
apiURL: "https://api.sonicscan.org/api",
apiURL: "https://api.etherscan.io/v2/api?chainId=146",
browserURL: "https://sonicscan.org",
},
},
Expand All @@ -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",
},
},
Expand Down
Loading