Skip to content

Commit

Permalink
Merge pull request #28 from matter-labs/db/update-verification
Browse files Browse the repository at this point in the history
feat: adds docs for zksync verifier
  • Loading branch information
dutterbutter authored Oct 18, 2024
2 parents f61f755 + 6bfd885 commit 27110ea
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 23 deletions.
28 changes: 15 additions & 13 deletions src/forge/deploying.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,28 @@ contract MyToken is ERC20 {
}
```

Additionally, we can tell Forge to verify our contract on Etherscan, Sourcify or Blockscout, if the network is supported, by passing `--verify`.
Additionally, we can tell Forge to verify our contract on ZKsync Block Explorer, Etherscan, Sourcify or Blockscout, if the network is supported, by passing `--verify`.

It is recommended to make use of ZKsync Block Explorer by specifying `--verifier zksync` and using the verification URL (e.g. ZKsync Sepolia `https://explorer.sepolia.era.zksync.dev/contract_verification`).

```sh
$ forge create --zksync \
--rpc-url <your_rpc_url> \
--constructor-args "ForgeUSD" "FUSD" 18 1000000000000000000000 \
--private-key <your_private_key> \
--etherscan-api-key <your_etherscan_api_key> \
--verifier zksync \
--verifier-url https://explorer.sepolia.era.zksync.dev/contract_verification \
--verify \
src/MyToken.sol:MyToken
```

## Verifying a pre-existing contract

It is recommended to use the `--verify` flag with `forge create` to automatically verify the contract on explorer after a deployment.
Note that for Etherscan [`ETHERSCAN_API_KEY`](../reference/config/etherscan.md#etherscan_api_key) must be set.
It is recommended to use the `--verify` flag with `forge create` to automatically verify the contract on explorer after a deployment using `--verifier zksync` to target ZKsync Block Explorer instance.

If you are verifying an already deployed contract, read on.

You can verify a contract on Etherscan, Sourcify, oklink or Blockscout with the [`forge verify-contract`](../reference/forge/forge-verify-contract.md) command.
You can verify a contract on ZKsync Block Explorer, Etherscan, Sourcify, oklink or Blockscout with the [`forge verify-contract`](../reference/forge/forge-verify-contract.md) command.

You must provide:
- the contract address
Expand All @@ -80,19 +82,19 @@ Here's how to verify it:
```bash
forge verify-contract \
--zksync \
--chain-id 11155111 \
--chain zksync-testnet \
--num-of-optimizations 1000000 \
--watch \
--verifier zksync \
--verifier-url https://explorer.sepolia.era.zksync.dev/contract_verification \
--constructor-args $(cast abi-encode "constructor(string,string,uint256,uint256)" "ForgeUSD" "FUSD" 18 1000000000000000000000) \
--etherscan-api-key <your_etherscan_api_key> \
--compiler-version v0.8.10+commit.fc410830 \
<the_contract_address> \
src/MyToken.sol:MyToken

Submitted contract for verification:
Response: `OK`
GUID: `a6yrbjp5prvakia6bqp5qdacczyfhkyi5j1r6qbds1js41ak1a`
url: https://sepolia.etherscan.io//address/0x6a54…3a4c#code
Submitting verification for [src/MyToken.sol:MyToken] at address 0x21d6dffe4B406c59E80CD62b4cB1763363c8a040.
Verification submitted successfully. Verification ID: 27574
Checking verification status for ID: 27574 using verifier: ZKsync at URL: https://explorer.sepolia.era.zksync.dev/contract_verification
Verification was successful.
```

It is recommended to use the [`--watch`](../reference/forge/forge-verify-contract.md#verify-contract-options) flag along
Expand All @@ -102,7 +104,7 @@ If the `--watch` flag was not supplied, you can check
the verification status with the [`forge verify-check`](../reference/forge/forge-verify-check.md) command:

```bash
$ forge verify-check --zksync --chain-id 11155111 <GUID> <your_etherscan_api_key>
$ forge verify-check --zksync --chain zksync-testnet <verificationId> --verifier zksync
Contract successfully verified.
```

Expand Down
4 changes: 2 additions & 2 deletions src/reference/common/verifier-options.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
`--verifier` *name*
&nbsp;&nbsp;&nbsp;&nbsp;The verification provider. Available options: `etherscan`, `sourcify` & `blockscout`. Default: `etherscan`. Note: make sure you add "/api\?" to the end of the Blockscout homepage explorer URL.
&nbsp;&nbsp;&nbsp;&nbsp;The verification provider. Available options: `zksync`,`etherscan`, `sourcify` & `blockscout`. Default: `etherscan`. Note: make sure you add "/api\?" to the end of the Blockscout homepage explorer URL.

`--verifier-url` *url*
&nbsp;&nbsp;&nbsp;&nbsp;The optional verifier url for submitting the verification request.
&nbsp;&nbsp;&nbsp;&nbsp;The optional verifier url for submitting the verification request.
&nbsp;&nbsp;&nbsp;&nbsp;Environment: `VERIFIER_URL`
5 changes: 4 additions & 1 deletion src/reference/forge/forge-verify-check.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ forge-verify-check - Check verification status on a chosen verification provider

``forge verify-check`` [*options*] *id* [*etherscan_key*]

The *id* is the verification identifier. For Etherscan & Bloxroute - it is the submission GUID, for Sourcify - it's the contract address.
The *id* is the verification identifier. For ZKsync Block Explorer it is
the verificationId.

For Etherscan & Bloxroute - it is the submission GUID, for Sourcify - it's the contract address.

### DESCRIPTION

Expand Down
20 changes: 13 additions & 7 deletions src/reference/forge/forge-verify-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,24 +88,30 @@ you can specify a file containing **space-separated** constructor arguments with

### EXAMPLES

1. Verify a contract with JSON standard input on Etherscan
1. Verify a contract on a ZKsync Block Explorer instance
```sh
forge verify-contract --verifier zksync \
--verifier-url http://localhost:5000 <address> SomeContract
```

2. Verify a contract with JSON standard input on Etherscan
```sh
forge verify-contract <address> SomeContract --watch
2. Verify a contract on a custom Sourcify instance
3. Verify a contract on a Sourcify instance
```sh
forge verify-contract --verifier sourcify \
--verifier-url http://localhost:5000 <address> SomeContract
```

3. Verify a flattened contract built with solc v0.8.11+commit.d7f03943:
4. Verify a flattened contract built with solc v0.8.11+commit.d7f03943:
```sh
forge verify-contract --flatten --watch --compiler-version "v0.8.11+commit.d7f03943" \
--constructor-args $(cast abi-encode "constructor(string,string,uint256,uint256)" "ForgeUSD" "FUSD" 18 1000000000000000000000) \
<address> MyToken
```

4. Verify a flattened contract by specifying constructor arguments in a file:
5. Verify a flattened contract by specifying constructor arguments in a file:
```sh
forge verify-contract --flatten --watch --compiler-version "v0.8.11+commit.d7f03943" \
--constructor-args-path constructor-args.txt <address> src/Token.sol:MyToken
Expand All @@ -115,17 +121,17 @@ you can specify a file containing **space-separated** constructor arguments with
ForgeUSD FUSD 18 1000000000000000000000
```

5. Verify a contract with Blockscout right after deployment (make sure you add "/api?" to the end of the Blockscout homepage explorer URL):
6. Verify a contract with Blockscout right after deployment (make sure you add "/api?" to the end of the Blockscout homepage explorer URL):
```sh
forge create --rpc-url <rpc_https_endpoint> --private-key $devTestnetPrivateKey src/Contract.sol:SimpleStorage --verify --verifier blockscout --verifier-url <blockscout_homepage_explorer_url>/api?
```

6. verify a contract with Oklink
7. verify a contract with Oklink
```sh
forge verify-contract 0x8CDDE82cFB4555D6ca21B5b28F97630265DA94c4 Counter --verifier oklink --verifier-url https://www.oklink.com/api/v5/explorer/contract/verify-source-code-plugin/XLAYER --api-key $OKLINK_API_KEY
```

7. verify a contract with Oklink while deploying
8. verify a contract with Oklink while deploying
```sh
forge create Counter --rpc-url <rpc_https_endpoint> --verify --verifier oklink --verifier-url https://www.oklink.com/api/v5/explorer/contract/verify-source-code-plugin/XLAYER --etherscan-api-key $OKLINK_API_KEY --private-key $PRIVATE_KEY --legacy
```
Expand Down

0 comments on commit 27110ea

Please sign in to comment.