Skip to content

Commit f0f93cd

Browse files
chore: add etherscan support for verify plugin (#252)
<!-- Thank you for contributing to the ZKsync Docs! Before submitting the PR, please make sure you do the following: - Update your PR title to follow [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) - Read the [Contributing Guide](https://github.com/matter-labs/zksync-docs/blob/main/CONTRIBUTING.md). - Understand our [Code of Conduct](https://github.com/matter-labs/zksync-docs/blob/main/CODE_OF_CONDUCT.md) - Please delete any unused parts of the template when submitting your PR --> # Description Add Etherscan as an interface option for the verification process. --------- Co-authored-by: Marko Arambasic <[email protected]>
1 parent 1138afa commit f0f93cd

File tree

2 files changed

+39
-29
lines changed

2 files changed

+39
-29
lines changed

content/00.zksync-era/40.tooling/20.hardhat/30.plugins/80.hardhat-zksync-verify.md

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ Import the plugin in the `hardhat.config.ts` file:
6666
import "@matterlabs/hardhat-zksync-verify";
6767
```
6868

69-
Add the `verifyURL` property to the ZKsync Era network in the `hardhat.config.ts` file as shown below:
70-
7169
```typescript
7270
networks: {
7371
sepolia: {
@@ -77,11 +75,33 @@ networks: {
7775
url: "%%zk_testnet_rpc_url%%", // The testnet RPC URL of ZKsync Era network.
7876
ethNetwork: "%%zk_testnet_identifier%%", // The Ethereum Web3 RPC URL, or the identifier of the network (e.g. `mainnet` or `sepolia`)
7977
zksync: true,
80-
// Verification endpoint for Sepolia
81-
verifyURL: '%%zk_testnet_contract_verification_url%%'
8278
}
8379
},
84-
// defaultNetwork: "zkTestnet", // optional (if not set, use '--network zkTestnet')
80+
```
81+
82+
#### Updates introduced in plugin version 1.7.0
83+
Etherscan verification is supported. To enable it, configure the etherscan property in the Hardhat configuration:
84+
85+
```typescript
86+
etherscan: {
87+
apiKey: 'APIKEY'
88+
}
89+
```
90+
91+
If the etherscan property is configured and enabled, verification will run on Etherscan.
92+
Otherwise, the plugin will default to verifying on the ZKsync block explorer.
93+
For more information on how to create api keys, please [visit the documentation](https://docs.zksync.network/getting-started/viewing-api-usage-statistics).
94+
For more information on how to configure etherscan for multiple api keys, please [visit the documentation](https://hardhat.org/hardhat-runner/plugins/nomicfoundation-hardhat-verify#multiple-api-keys-and-alternative-block-explorers)
95+
The plugin provides pre-configured chain settings `zksyncsepolia` and `zksyncmainnet`, so users don't need to create custom chains.
96+
97+
```typescript
98+
etherscan: {
99+
apiKey: {
100+
......
101+
zksyncsepolia: 'APIKEY',
102+
zksyncmainnet: 'APIKEY'
103+
}
104+
}
85105
```
86106

87107
Additional network properties:
@@ -97,24 +117,19 @@ or the default `ethers` provider for the network if the configuration is not pro
97117
- `zksync` is a flag that indicates a ZKsync Era network configuration. This field is set to `true` for all ZKsync Era networks.
98118
If you want to run a `hardhat-verify` verification, this field needs to be set to `false`.
99119
If set to `true`, the verification process will try to run the verification process on the ZKsync Era network.
100-
- `verifyURL` is a field that points to the verification endpoint for the specific ZKsync network.
101-
This parameter is optional, and its default value is the testnet verification url.
102-
- Testnet: `%%zk_testnet_contract_verification_url%%`
103-
- Mainnet: `%%zk_mainnet_contract_verification_url%%`
104-
105-
If you want to verify a smart contract on the Ethereum in the same project,
106-
it is important to add `etherscan` field and API key in the `hardhat.config.ts` file:
107-
108-
```typescript
120+
- `verifyURL` is a field that specifies the verification endpoint for the connected ZKsync network.
121+
From version 1.7.0, the plugin automatically resolves this endpoint based on the network configuration.
122+
If you are using a custom chain with an API compatible with the zksync block explorer, you can manually set the URL here.
123+
- `browserVerifyURL` - Introduced in version 1.7.0 of the plugin, this field automatically resolves the browser URL based on the network configuration.
124+
If you're using a custom chain, you can manually specify the URL here.
125+
- `enableVerifyURL` - Introduced in version 1.7.0 of the plugin, this flag forces verification on the ZKsync block explorer.
126+
It allows you to verify the same contract on both Etherscan and the ZKsync block explorer.
109127

110-
networks: {
111-
...
112-
},
113-
etherscan: {
114-
apiKey: //<Your API key for Etherscan>,
115-
},
116-
117-
```
128+
::callout{icon="i-heroicons-exclamation-triangle" color="amber"}
129+
**verifyURL, browserVerifyURL and enableVerifyURL usage**
130+
These properties are only for ZKsync block explorer verifications and do not affect Etherscan verifications,
131+
as all Etherscan configurations are handled through the etherscan object.
132+
::
118133

119134
### Commands
120135

@@ -179,13 +194,6 @@ The verification process consists of two steps:
179194
- A verification request is sent to confirm if the given parameters for your contract are correct.
180195
- Then, we check the verification status of that request.
181196
Both steps run when you run the `verify` task, but you will be able to see your specific verification request ID.
182-
You can then use this ID to check the status of your verification request without running the whole process from the beginning.
183-
184-
The following command checks the status of the verification request for the specific verification ID:
185-
186-
```sh
187-
yarn hardhat verify-status --verification-id <your verification id>
188-
```
189197

190198
### Verify smart contract programmatically
191199

cspell-config/cspell-zksync.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,5 @@ ERAVM
3131
foundryup-zksync
3232
foundryup
3333
zkvm
34+
zksyncsepolia
35+
zksyncmainnet

0 commit comments

Comments
 (0)