From 9e9086bf61b8e355b4950c48e6e8bec81698a4f5 Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Sat, 5 Oct 2024 19:49:42 -0500 Subject: [PATCH] feat: adds docs for zksync verifier --- src/forge/deploying.md | 28 +++++++++++--------- src/reference/common/verifier-options.md | 4 +-- src/reference/forge/forge-verify-check.md | 5 +++- src/reference/forge/forge-verify-contract.md | 20 +++++++++----- 4 files changed, 34 insertions(+), 23 deletions(-) diff --git a/src/forge/deploying.md b/src/forge/deploying.md index 89a546515..c07ba0dc7 100644 --- a/src/forge/deploying.md +++ b/src/forge/deploying.md @@ -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 \ --constructor-args "ForgeUSD" "FUSD" 18 1000000000000000000000 \ --private-key \ - --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 @@ -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 \ - --compiler-version v0.8.10+commit.fc410830 \ \ 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 @@ -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 +$ forge verify-check --zksync --chain zksync-testnet --verifier zksync Contract successfully verified. ``` diff --git a/src/reference/common/verifier-options.md b/src/reference/common/verifier-options.md index 037f27c30..9cec8e479 100644 --- a/src/reference/common/verifier-options.md +++ b/src/reference/common/verifier-options.md @@ -1,6 +1,6 @@ `--verifier` *name* -    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. +    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* -    The optional verifier url for submitting the verification request. +    The optional verifier url for submitting the verification request.     Environment: `VERIFIER_URL` diff --git a/src/reference/forge/forge-verify-check.md b/src/reference/forge/forge-verify-check.md index 95fc66f85..682c1321c 100644 --- a/src/reference/forge/forge-verify-check.md +++ b/src/reference/forge/forge-verify-check.md @@ -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 diff --git a/src/reference/forge/forge-verify-contract.md b/src/reference/forge/forge-verify-contract.md index e0e4e1d22..237d92962 100644 --- a/src/reference/forge/forge-verify-contract.md +++ b/src/reference/forge/forge-verify-contract.md @@ -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
SomeContract + ``` + +2. Verify a contract with JSON standard input on Etherscan ```sh forge verify-contract
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
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) \
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
src/Token.sol:MyToken @@ -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 --private-key $devTestnetPrivateKey src/Contract.sol:SimpleStorage --verify --verifier blockscout --verifier-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 --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 ```