From 9e9086bf61b8e355b4950c48e6e8bec81698a4f5 Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Sat, 5 Oct 2024 19:49:42 -0500 Subject: [PATCH 1/3] 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 ``` From 78e8b1b7531565ddd6282a867b7454eb863e6f5d Mon Sep 17 00:00:00 2001 From: elfedy Date: Mon, 14 Oct 2024 16:49:49 -0300 Subject: [PATCH 2/3] feat: add non-inlinable libraries section --- src/SUMMARY.md | 1 + src/zksync-specifics/README.md | 1 + .../non-inlinable-libraries.md | 28 +++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 src/zksync-specifics/non-inlinable-libraries.md diff --git a/src/SUMMARY.md b/src/SUMMARY.md index f351d98d7..683cde8dd 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -21,6 +21,7 @@ - [Overview](./zksync-specifics/README.md) - [Execution Overview](./zksync-specifics/execution-overview.md) - [Compilation Overview](./zksync-specifics/compilation-overview.md) +- [Non Inlinable Libraries](./zksync-specifics/non-inlinable-libraries.md) - [Configuration Overview](./zksync-specifics/configuration-overview.md) - [Limitations](./zksync-specifics/limitations/README.md) - [General](./zksync-specifics/limitations/general.md) diff --git a/src/zksync-specifics/README.md b/src/zksync-specifics/README.md index 3e45066cc..4bf602dd6 100644 --- a/src/zksync-specifics/README.md +++ b/src/zksync-specifics/README.md @@ -2,6 +2,7 @@ - [Execution Overview](execution-overview.md) - [Compilation Overview](compilation-overview.md) +- [Non Inlinable Libraries](non-inlinable-libraries.md) - [Limitations](limitations/README.md) - [General](limitations/general.md) - [Compilation](limitations/compilation.md) diff --git a/src/zksync-specifics/non-inlinable-libraries.md b/src/zksync-specifics/non-inlinable-libraries.md new file mode 100644 index 000000000..4f4acc9fc --- /dev/null +++ b/src/zksync-specifics/non-inlinable-libraries.md @@ -0,0 +1,28 @@ +## Non inlinable libraries + +Compiling contracts without linking non-inlinable libraries is currently not supported. Libraries need to be deployed before building contracts using them. + +When building the contracts, the addresses need to be passed using the `libraries` config which contains a list of `CONTRACT_PATH`:`ADDRESS` mappings. + +on `foundry.toml`: + +```toml +libraries = [ + "src/MyLibrary.sol:MyLibrary:0xfD88CeE74f7D78697775aBDAE53f9Da1559728E4" +] +``` + +as a `cli` flag: + +```bash +forge build --zksync --libraries src/MyLibrary.sol:MyLibrary:0xfD88CeE74f7D78697775aBDAE53f9Da1559728E4 + +``` + +For more information please refer to [official docs](https://docs.zksync.io/build/developer-reference/ethereum-differences/libraries). + +### Listing missing libraries + +To scan missing non-inlinable libraries, you can build the project using the `--zk-detect-missing-libraries` flag. This will give a list of the libraries that need to be deployed and their addresses provided via the `libraries` option for the contracts to compile. Metadata about the libraries will be saved in `.zksolc-libraries-cache/missing_library_dependencies.json`. + + From f185787f1daf33a545e697de65eb278c9bf7e580 Mon Sep 17 00:00:00 2001 From: elfedy Date: Tue, 15 Oct 2024 14:01:46 -0300 Subject: [PATCH 3/3] Move non-inlinable libraries to compilation limitations section --- src/SUMMARY.md | 1 - src/zksync-specifics/README.md | 1 - .../limitations/compilation.md | 31 ++++++++++++++++++- .../non-inlinable-libraries.md | 28 ----------------- 4 files changed, 30 insertions(+), 31 deletions(-) delete mode 100644 src/zksync-specifics/non-inlinable-libraries.md diff --git a/src/SUMMARY.md b/src/SUMMARY.md index 683cde8dd..f351d98d7 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -21,7 +21,6 @@ - [Overview](./zksync-specifics/README.md) - [Execution Overview](./zksync-specifics/execution-overview.md) - [Compilation Overview](./zksync-specifics/compilation-overview.md) -- [Non Inlinable Libraries](./zksync-specifics/non-inlinable-libraries.md) - [Configuration Overview](./zksync-specifics/configuration-overview.md) - [Limitations](./zksync-specifics/limitations/README.md) - [General](./zksync-specifics/limitations/general.md) diff --git a/src/zksync-specifics/README.md b/src/zksync-specifics/README.md index 4bf602dd6..3e45066cc 100644 --- a/src/zksync-specifics/README.md +++ b/src/zksync-specifics/README.md @@ -2,7 +2,6 @@ - [Execution Overview](execution-overview.md) - [Compilation Overview](compilation-overview.md) -- [Non Inlinable Libraries](non-inlinable-libraries.md) - [Limitations](limitations/README.md) - [General](limitations/general.md) - [Compilation](limitations/compilation.md) diff --git a/src/zksync-specifics/limitations/compilation.md b/src/zksync-specifics/limitations/compilation.md index 49493a375..599054146 100644 --- a/src/zksync-specifics/limitations/compilation.md +++ b/src/zksync-specifics/limitations/compilation.md @@ -77,4 +77,33 @@ There are three possible solutions to address this issue: contract MainContract is ContractPart1, ContractPart2 { // Logic to combine the functionalities of both parts } - ``` \ No newline at end of file + ``` + +### Non inlinable libraries + +Compiling contracts without linking non-inlinable libraries is currently not supported. Libraries need to be deployed before building contracts using them. + +When building the contracts, the addresses need to be passed using the `libraries` config which contains a list of `CONTRACT_PATH`:`ADDRESS` mappings. + +on `foundry.toml`: + +```toml +libraries = [ + "src/MyLibrary.sol:MyLibrary:0xfD88CeE74f7D78697775aBDAE53f9Da1559728E4" +] +``` + +as a `cli` flag: + +```bash +forge build --zksync --libraries src/MyLibrary.sol:MyLibrary:0xfD88CeE74f7D78697775aBDAE53f9Da1559728E4 + +``` + +For more information please refer to [official docs](https://docs.zksync.io/build/developer-reference/ethereum-differences/libraries). + +#### Listing missing libraries + +To scan missing non-inlinable libraries, you can build the project using the `--zk-detect-missing-libraries` flag. This will give a list of the libraries that need to be deployed and their addresses provided via the `libraries` option for the contracts to compile. Metadata about the libraries will be saved in `.zksolc-libraries-cache/missing_library_dependencies.json`. + + diff --git a/src/zksync-specifics/non-inlinable-libraries.md b/src/zksync-specifics/non-inlinable-libraries.md deleted file mode 100644 index 4f4acc9fc..000000000 --- a/src/zksync-specifics/non-inlinable-libraries.md +++ /dev/null @@ -1,28 +0,0 @@ -## Non inlinable libraries - -Compiling contracts without linking non-inlinable libraries is currently not supported. Libraries need to be deployed before building contracts using them. - -When building the contracts, the addresses need to be passed using the `libraries` config which contains a list of `CONTRACT_PATH`:`ADDRESS` mappings. - -on `foundry.toml`: - -```toml -libraries = [ - "src/MyLibrary.sol:MyLibrary:0xfD88CeE74f7D78697775aBDAE53f9Da1559728E4" -] -``` - -as a `cli` flag: - -```bash -forge build --zksync --libraries src/MyLibrary.sol:MyLibrary:0xfD88CeE74f7D78697775aBDAE53f9Da1559728E4 - -``` - -For more information please refer to [official docs](https://docs.zksync.io/build/developer-reference/ethereum-differences/libraries). - -### Listing missing libraries - -To scan missing non-inlinable libraries, you can build the project using the `--zk-detect-missing-libraries` flag. This will give a list of the libraries that need to be deployed and their addresses provided via the `libraries` option for the contracts to compile. Metadata about the libraries will be saved in `.zksolc-libraries-cache/missing_library_dependencies.json`. - -