From 7ec94417a1e678df8700a47142ecd685c1242679 Mon Sep 17 00:00:00 2001 From: Sabrina Date: Wed, 31 Jul 2024 11:34:14 -0400 Subject: [PATCH] docs: update the zksync-cli section (#165) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Description Update the ZKsync CLI section of the documentation with new pages for guides and refreshed CLI reference pages. Moved the Quickstart and ZKsync 101 into a new section called "Start coding πŸš€". ## Linked Issues Resolves DEVRL-792 --- content/00.build/00.index.md | 4 +- content/00.build/01.connect-to-zksync.md | 2 +- .../05.quick-start/1.index.md | 4 +- .../3.deploy-your-first-contract.md | 2 +- .../05.quick-start/4.erc20-token.md | 2 +- .../5.paymasters-introduction.md | 4 +- .../_deploy_first/_atlas_deploy_contract.md | 0 .../_deploy_first/_remix_deploy_contract.md | 0 .../05.quick-start/_dir.yml | 0 .../_erc20_tutorial/_atlas_erc20_tutorial.md | 0 .../_erc20_tutorial/_remix_erc20_tutorial.md | 0 .../_atlas_paymaster_intro.md | 4 +- .../_remix_paymaster_intro.md | 4 +- .../10.zksync-101/00.index.md | 2 +- .../10.zksync-101/10.hello-zksync.md | 4 +- .../10.zksync-101/20.contract-factory.md | 2 +- .../10.zksync-101/30.testing.md | 2 +- .../10.zksync-101/40.upgrading.md | 2 +- .../10.zksync-101/50.paymaster.md | 0 .../_foundry_deploy_contract_factory.md | 2 +- .../_hardhat_deploy_contract_factory.md | 2 +- .../10.zksync-101/_dir.yml | 0 .../_hello-zksync/_foundry_deploy_contract.md | 2 +- .../_hello-zksync/_hardhat_deploy_contract.md | 2 +- .../10.zksync-101/_partials/_setup-wallet.md | 2 +- .../_paymasters/_approval_paymaster_flow.md | 2 +- .../_paymasters/_general_paymaster_flow.md | 2 +- .../_testing/_foundry_contract_testing.md | 0 .../_testing/_hardhat_contract_testing.md | 3 +- .../_foundry_beacon_contract_upgradability.md | 0 .../_hardhat_beacon_contract_upgradability.md | 2 +- .../_beacon_proxy_contract_upgradability.md | 0 ...ndry_transparent_contract_upgradability.md | 0 ...dhat_transparent_contract_upgradability.md | 2 +- ...ransparent_proxy_contract_upgradability.md | 0 .../_foundry_uups_contract_upgradability.md | 0 .../_hardhat_uups_contract_upgradability.md | 2 +- .../_uups_contract_upgradability.md | 0 content/00.build/05.start-coding/_dir.yml | 1 + content/00.build/20.zksync-cli/00.index.md | 46 ++-- .../05.reading-transaction-data.md | 80 ++++++ .../20.zksync-cli/10.wallet-actions.md | 71 +++++ .../20.zksync-cli/10.zksync-cli-dev.md | 52 ---- content/00.build/20.zksync-cli/20.bridging.md | 139 ++++++++++ .../30.interact-with-contracts.md | 208 +++++++++++++++ .../20.zksync-cli/30.zksync-cli-contract.md | 245 ------------------ .../20.zksync-cli/35.creating-projects.md | 83 ++++++ .../20.zksync-cli/40.running-a-node.md | 94 +++++++ .../40.zksync-cli-transaction.md | 87 ------- .../20.zksync-cli/50.configuring-chains.md | 87 +++++++ .../20.zksync-cli/50.zksync-cli-wallet.md | 67 ----- ...oubleshooting.md => 60.troubleshooting.md} | 44 ++-- .../20.zksync-cli/60.zksync-cli-bridge.md | 91 ------- .../70.zksync-cli-config-chains.md | 33 --- .../20.zksync-cli/90.reference/00.index.md | 12 + .../90.reference/05.zksync-cli-bridge.md | 104 ++++++++ .../15.zksync-cli-config-chains.md | 39 +++ .../90.reference/19.zksync-cli-contract.md | 117 +++++++++ .../20.zksync-cli-create.md | 29 +-- .../90.reference/25.zksync-cli-dev.md | 113 ++++++++ .../90.reference/40.zksync-cli-transaction.md | 39 +++ .../90.reference/50.zksync-cli-wallet.md | 59 +++++ .../20.zksync-cli/90.reference/_dir.yml | 1 + .../20.hardhat/60.hardhat-zksync-deploy.md | 2 +- .../30.documentation-styleguide.md | 6 +- content/index.yml | 2 +- firebase.json | 16 +- 67 files changed, 1355 insertions(+), 673 deletions(-) rename content/00.build/{ => 05.start-coding}/05.quick-start/1.index.md (85%) rename content/00.build/{ => 05.start-coding}/05.quick-start/3.deploy-your-first-contract.md (99%) rename content/00.build/{ => 05.start-coding}/05.quick-start/4.erc20-token.md (96%) rename content/00.build/{ => 05.start-coding}/05.quick-start/5.paymasters-introduction.md (97%) rename content/00.build/{ => 05.start-coding}/05.quick-start/_deploy_first/_atlas_deploy_contract.md (100%) rename content/00.build/{ => 05.start-coding}/05.quick-start/_deploy_first/_remix_deploy_contract.md (100%) rename content/00.build/{ => 05.start-coding}/05.quick-start/_dir.yml (100%) rename content/00.build/{ => 05.start-coding}/05.quick-start/_erc20_tutorial/_atlas_erc20_tutorial.md (100%) rename content/00.build/{ => 05.start-coding}/05.quick-start/_erc20_tutorial/_remix_erc20_tutorial.md (100%) rename content/00.build/{ => 05.start-coding}/05.quick-start/_paymaster_intro/_atlas_paymaster_intro.md (95%) rename content/00.build/{ => 05.start-coding}/05.quick-start/_paymaster_intro/_remix_paymaster_intro.md (95%) rename content/00.build/{ => 05.start-coding}/10.zksync-101/00.index.md (97%) rename content/00.build/{ => 05.start-coding}/10.zksync-101/10.hello-zksync.md (94%) rename content/00.build/{ => 05.start-coding}/10.zksync-101/20.contract-factory.md (97%) rename content/00.build/{ => 05.start-coding}/10.zksync-101/30.testing.md (97%) rename content/00.build/{ => 05.start-coding}/10.zksync-101/40.upgrading.md (97%) rename content/00.build/{ => 05.start-coding}/10.zksync-101/50.paymaster.md (100%) rename content/00.build/{ => 05.start-coding}/10.zksync-101/_deploy_factory/_foundry_deploy_contract_factory.md (98%) rename content/00.build/{ => 05.start-coding}/10.zksync-101/_deploy_factory/_hardhat_deploy_contract_factory.md (98%) rename content/00.build/{ => 05.start-coding}/10.zksync-101/_dir.yml (100%) rename content/00.build/{ => 05.start-coding}/10.zksync-101/_hello-zksync/_foundry_deploy_contract.md (98%) rename content/00.build/{ => 05.start-coding}/10.zksync-101/_hello-zksync/_hardhat_deploy_contract.md (98%) rename content/00.build/{ => 05.start-coding}/10.zksync-101/_partials/_setup-wallet.md (80%) rename content/00.build/{ => 05.start-coding}/10.zksync-101/_paymasters/_approval_paymaster_flow.md (99%) rename content/00.build/{ => 05.start-coding}/10.zksync-101/_paymasters/_general_paymaster_flow.md (99%) rename content/00.build/{ => 05.start-coding}/10.zksync-101/_testing/_foundry_contract_testing.md (100%) rename content/00.build/{ => 05.start-coding}/10.zksync-101/_testing/_hardhat_contract_testing.md (98%) rename content/00.build/{ => 05.start-coding}/10.zksync-101/_upgrading/_beacon/_foundry_beacon_contract_upgradability.md (100%) rename content/00.build/{ => 05.start-coding}/10.zksync-101/_upgrading/_beacon/_hardhat_beacon_contract_upgradability.md (99%) rename content/00.build/{ => 05.start-coding}/10.zksync-101/_upgrading/_beacon_proxy_contract_upgradability.md (100%) rename content/00.build/{ => 05.start-coding}/10.zksync-101/_upgrading/_transparent/_foundry_transparent_contract_upgradability.md (100%) rename content/00.build/{ => 05.start-coding}/10.zksync-101/_upgrading/_transparent/_hardhat_transparent_contract_upgradability.md (99%) rename content/00.build/{ => 05.start-coding}/10.zksync-101/_upgrading/_transparent_proxy_contract_upgradability.md (100%) rename content/00.build/{ => 05.start-coding}/10.zksync-101/_upgrading/_uups/_foundry_uups_contract_upgradability.md (100%) rename content/00.build/{ => 05.start-coding}/10.zksync-101/_upgrading/_uups/_hardhat_uups_contract_upgradability.md (99%) rename content/00.build/{ => 05.start-coding}/10.zksync-101/_upgrading/_uups_contract_upgradability.md (100%) create mode 100644 content/00.build/05.start-coding/_dir.yml create mode 100644 content/00.build/20.zksync-cli/05.reading-transaction-data.md create mode 100644 content/00.build/20.zksync-cli/10.wallet-actions.md delete mode 100644 content/00.build/20.zksync-cli/10.zksync-cli-dev.md create mode 100644 content/00.build/20.zksync-cli/20.bridging.md create mode 100644 content/00.build/20.zksync-cli/30.interact-with-contracts.md delete mode 100644 content/00.build/20.zksync-cli/30.zksync-cli-contract.md create mode 100644 content/00.build/20.zksync-cli/35.creating-projects.md create mode 100644 content/00.build/20.zksync-cli/40.running-a-node.md delete mode 100644 content/00.build/20.zksync-cli/40.zksync-cli-transaction.md create mode 100644 content/00.build/20.zksync-cli/50.configuring-chains.md delete mode 100644 content/00.build/20.zksync-cli/50.zksync-cli-wallet.md rename content/00.build/20.zksync-cli/{01.troubleshooting.md => 60.troubleshooting.md} (50%) delete mode 100644 content/00.build/20.zksync-cli/60.zksync-cli-bridge.md delete mode 100644 content/00.build/20.zksync-cli/70.zksync-cli-config-chains.md create mode 100644 content/00.build/20.zksync-cli/90.reference/00.index.md create mode 100644 content/00.build/20.zksync-cli/90.reference/05.zksync-cli-bridge.md create mode 100644 content/00.build/20.zksync-cli/90.reference/15.zksync-cli-config-chains.md create mode 100644 content/00.build/20.zksync-cli/90.reference/19.zksync-cli-contract.md rename content/00.build/20.zksync-cli/{ => 90.reference}/20.zksync-cli-create.md (71%) create mode 100644 content/00.build/20.zksync-cli/90.reference/25.zksync-cli-dev.md create mode 100644 content/00.build/20.zksync-cli/90.reference/40.zksync-cli-transaction.md create mode 100644 content/00.build/20.zksync-cli/90.reference/50.zksync-cli-wallet.md create mode 100644 content/00.build/20.zksync-cli/90.reference/_dir.yml diff --git a/content/00.build/00.index.md b/content/00.build/00.index.md index 7f7896c5..6a390491 100644 --- a/content/00.build/00.index.md +++ b/content/00.build/00.index.md @@ -8,7 +8,7 @@ description: Welcome to the ZKsync Era Docs. --- title: Quickstart icon: i-heroicons-rocket-launch-solid - to: /build/quick-start + to: /build/start-coding/quick-start --- Experience a quick tutorial on building and deploying smart contracts on ZKsync Era. :: @@ -16,7 +16,7 @@ description: Welcome to the ZKsync Era Docs. --- title: ZKsync 101 icon: i-heroicons-academic-cap-solid - to: /build/zksync-101 + to: /build/start-coding/zksync-101 --- Learn to build projects locally for ZKsync Era using zksync-cli. :: diff --git a/content/00.build/01.connect-to-zksync.md b/content/00.build/01.connect-to-zksync.md index 50a19b7e..36537950 100644 --- a/content/00.build/01.connect-to-zksync.md +++ b/content/00.build/01.connect-to-zksync.md @@ -31,4 +31,4 @@ To manually add ZKsync Era as a custom network in your wallet, follow these step Once you have your wallet connected to a ZKsync Era environment, you can get testnet funds from one of many [testnet faucets](/ecosystem/network-faucets) -to use with [deploying your first smart contract](/build/quick-start/deploy-your-first-contract). +to use with [deploying your first smart contract](/build/start-coding/quick-start/deploy-your-first-contract). diff --git a/content/00.build/05.quick-start/1.index.md b/content/00.build/05.start-coding/05.quick-start/1.index.md similarity index 85% rename from content/00.build/05.quick-start/1.index.md rename to content/00.build/05.start-coding/05.quick-start/1.index.md index cbed3410..ea7343bb 100644 --- a/content/00.build/05.quick-start/1.index.md +++ b/content/00.build/05.start-coding/05.quick-start/1.index.md @@ -16,7 +16,7 @@ to help you learn as quickly and efficiently as possible. ## Get started - If you haven't already added ZKsync Era to your wallet, follow the instructions in [Connect ZKsync Era to your wallet](/build/connect-to-zksync). -- Continue to [Deploy your first contract](/build/quick-start/deploy-your-first-contract) to learn how to use Remix or Atlas +- Continue to [Deploy your first contract](/build/start-coding/quick-start/deploy-your-first-contract) to learn how to use Remix or Atlas to deploy a contract onto ZKsync Era. - If you are familiar with ZKsync Era and want to develop using `zksync-cli` locally - on your machine, you can jump over to the [ZKsync 101](/build/zksync-101) section. + on your machine, you can jump over to the [ZKsync 101](/build/start-coding/zksync-101) section. diff --git a/content/00.build/05.quick-start/3.deploy-your-first-contract.md b/content/00.build/05.start-coding/05.quick-start/3.deploy-your-first-contract.md similarity index 99% rename from content/00.build/05.quick-start/3.deploy-your-first-contract.md rename to content/00.build/05.start-coding/05.quick-start/3.deploy-your-first-contract.md index 80fc76c3..49d67117 100644 --- a/content/00.build/05.quick-start/3.deploy-your-first-contract.md +++ b/content/00.build/05.start-coding/05.quick-start/3.deploy-your-first-contract.md @@ -121,7 +121,7 @@ ZK is the endgame ✌️ ## Next steps -- Continue learning by [deploying an ERC20 token to ZKsync](/build/quick-start/erc20-token). +- Continue learning by [deploying an ERC20 token to ZKsync](/build/start-coding/quick-start/erc20-token). - Join the [ZKsync developer community in Discord](https://join.zksync.dev/) where you can ask any questions about this tutorial in the `#dev-quickstart` channel. - Join our [GitHub Discussions Community](%%zk_git_repo_zksync-developers%%/discussions/) to diff --git a/content/00.build/05.quick-start/4.erc20-token.md b/content/00.build/05.start-coding/05.quick-start/4.erc20-token.md similarity index 96% rename from content/00.build/05.quick-start/4.erc20-token.md rename to content/00.build/05.start-coding/05.quick-start/4.erc20-token.md index dbc35654..580af675 100644 --- a/content/00.build/05.quick-start/4.erc20-token.md +++ b/content/00.build/05.start-coding/05.quick-start/4.erc20-token.md @@ -48,7 +48,7 @@ The ERC20 token code is provided β€œas is” without any express or implied warr ## Next steps -- Continue learning about [paymasters and paying transaction fees with this ERC20 token](/build/quick-start/paymasters-introduction). +- Continue learning about [paymasters and paying transaction fees with this ERC20 token](/build/start-coding/quick-start/paymasters-introduction). - Join the [ZKsync developer community in Discord](https://join.zksync.dev/) where you can ask any questions about this tutorial in the `#dev-quickstart` channel. - Join our [GitHub Discussions Community](%%zk_git_repo_zksync-developers%%/discussions/) to diff --git a/content/00.build/05.quick-start/5.paymasters-introduction.md b/content/00.build/05.start-coding/05.quick-start/5.paymasters-introduction.md similarity index 97% rename from content/00.build/05.quick-start/5.paymasters-introduction.md rename to content/00.build/05.start-coding/05.quick-start/5.paymasters-introduction.md index 3802e38a..d0d1ed3e 100644 --- a/content/00.build/05.quick-start/5.paymasters-introduction.md +++ b/content/00.build/05.start-coding/05.quick-start/5.paymasters-introduction.md @@ -4,7 +4,7 @@ description: Learn about paymasters and use one to pay transaction fees with you --- This tutorial makes use of smart contracts deployed in the previous two tutorials, -[Deploy your first contract](/build/quick-start/deploy-your-first-contract) and [Create an ERC20 token](/build/quick-start/erc20-token). +[Deploy your first contract](/build/start-coding/quick-start/deploy-your-first-contract) and [Create an ERC20 token](/build/start-coding/quick-start/erc20-token). This section introduces one of the custom features of ZKsync: native account abstraction and paymasters. @@ -193,4 +193,4 @@ items: [{ - Learn more about paymasters and native account abstraction in [this section of the docs](/build/developer-reference/account-abstraction/). - Browse different paymaster examples in [this open source repository](https://github.com/matter-labs/paymaster-examples). -- Continue learning in ZKsync 101 by building a [GoFundMe clone](/build/zksync-101). +- Continue learning in ZKsync 101 by building a [GoFundMe clone](/build/start-coding/zksync-101). diff --git a/content/00.build/05.quick-start/_deploy_first/_atlas_deploy_contract.md b/content/00.build/05.start-coding/05.quick-start/_deploy_first/_atlas_deploy_contract.md similarity index 100% rename from content/00.build/05.quick-start/_deploy_first/_atlas_deploy_contract.md rename to content/00.build/05.start-coding/05.quick-start/_deploy_first/_atlas_deploy_contract.md diff --git a/content/00.build/05.quick-start/_deploy_first/_remix_deploy_contract.md b/content/00.build/05.start-coding/05.quick-start/_deploy_first/_remix_deploy_contract.md similarity index 100% rename from content/00.build/05.quick-start/_deploy_first/_remix_deploy_contract.md rename to content/00.build/05.start-coding/05.quick-start/_deploy_first/_remix_deploy_contract.md diff --git a/content/00.build/05.quick-start/_dir.yml b/content/00.build/05.start-coding/05.quick-start/_dir.yml similarity index 100% rename from content/00.build/05.quick-start/_dir.yml rename to content/00.build/05.start-coding/05.quick-start/_dir.yml diff --git a/content/00.build/05.quick-start/_erc20_tutorial/_atlas_erc20_tutorial.md b/content/00.build/05.start-coding/05.quick-start/_erc20_tutorial/_atlas_erc20_tutorial.md similarity index 100% rename from content/00.build/05.quick-start/_erc20_tutorial/_atlas_erc20_tutorial.md rename to content/00.build/05.start-coding/05.quick-start/_erc20_tutorial/_atlas_erc20_tutorial.md diff --git a/content/00.build/05.quick-start/_erc20_tutorial/_remix_erc20_tutorial.md b/content/00.build/05.start-coding/05.quick-start/_erc20_tutorial/_remix_erc20_tutorial.md similarity index 100% rename from content/00.build/05.quick-start/_erc20_tutorial/_remix_erc20_tutorial.md rename to content/00.build/05.start-coding/05.quick-start/_erc20_tutorial/_remix_erc20_tutorial.md diff --git a/content/00.build/05.quick-start/_paymaster_intro/_atlas_paymaster_intro.md b/content/00.build/05.start-coding/05.quick-start/_paymaster_intro/_atlas_paymaster_intro.md similarity index 95% rename from content/00.build/05.quick-start/_paymaster_intro/_atlas_paymaster_intro.md rename to content/00.build/05.start-coding/05.quick-start/_paymaster_intro/_atlas_paymaster_intro.md index d8f6d0da..8978bbc9 100644 --- a/content/00.build/05.quick-start/_paymaster_intro/_atlas_paymaster_intro.md +++ b/content/00.build/05.start-coding/05.quick-start/_paymaster_intro/_atlas_paymaster_intro.md @@ -110,8 +110,8 @@ Finally we retrieve and print the ETH and ERC20 balances to see how they’ve ch ## Run the script To run the script, first enter the addresses of the `ZeekMessages.sol` and `TestToken.sol` contracts that we -deployed previously ([Deploy your first contract](/build/quick-start/deploy-your-first-contract) and -[Erc20 Token](/build/quick-start/erc20-token)) in the following variables at the beginning of +deployed previously ([Deploy your first contract](/build/start-coding/quick-start/deploy-your-first-contract) and +[Erc20 Token](/build/start-coding/quick-start/erc20-token)) in the following variables at the beginning of the script: ```typescript diff --git a/content/00.build/05.quick-start/_paymaster_intro/_remix_paymaster_intro.md b/content/00.build/05.start-coding/05.quick-start/_paymaster_intro/_remix_paymaster_intro.md similarity index 95% rename from content/00.build/05.quick-start/_paymaster_intro/_remix_paymaster_intro.md rename to content/00.build/05.start-coding/05.quick-start/_paymaster_intro/_remix_paymaster_intro.md index c009384a..69ed5eb0 100644 --- a/content/00.build/05.quick-start/_paymaster_intro/_remix_paymaster_intro.md +++ b/content/00.build/05.start-coding/05.quick-start/_paymaster_intro/_remix_paymaster_intro.md @@ -116,8 +116,8 @@ Finally we retrieve and print the ETH and ERC20 balances to see how they’ve ch ## Run the script To run the script, first enter the addresses of the `ZeekMessages.sol` and `TestToken.sol` contracts that we -deployed previously ([Deploy your first contract](/build/quick-start/deploy-your-first-contract) and -[Erc20 Token](/build/quick-start/erc20-token)) in the following variables at the beginning of +deployed previously ([Deploy your first contract](/build/start-coding/quick-start/deploy-your-first-contract) and +[Erc20 Token](/build/start-coding/quick-start/erc20-token)) in the following variables at the beginning of the script: ```typescript diff --git a/content/00.build/10.zksync-101/00.index.md b/content/00.build/05.start-coding/10.zksync-101/00.index.md similarity index 97% rename from content/00.build/10.zksync-101/00.index.md rename to content/00.build/05.start-coding/10.zksync-101/00.index.md index 5ecdbe09..4d773693 100644 --- a/content/00.build/10.zksync-101/00.index.md +++ b/content/00.build/05.start-coding/10.zksync-101/00.index.md @@ -136,6 +136,6 @@ If you did not set up a local era node for development and plan to use %%zk_test You should now have a fully working local environment to build new projects on ZKsync! -- Continue to [Hello ZKsync!](/build/zksync-101/hello-zksync) to begin the series on building a crowdfunding campaign for Zeek. +- Continue to [Hello ZKsync!](/build/start-coding/zksync-101/hello-zksync) to begin the series on building a crowdfunding campaign for Zeek. - This setup provides you everything you need to build in ZKsync. You can skip on to creating your own projects using `zksync-cli` with your fully set up local dev environment. diff --git a/content/00.build/10.zksync-101/10.hello-zksync.md b/content/00.build/05.start-coding/10.zksync-101/10.hello-zksync.md similarity index 94% rename from content/00.build/10.zksync-101/10.hello-zksync.md rename to content/00.build/05.start-coding/10.zksync-101/10.hello-zksync.md index 2903cfd1..dad59c19 100644 --- a/content/00.build/10.zksync-101/10.hello-zksync.md +++ b/content/00.build/05.start-coding/10.zksync-101/10.hello-zksync.md @@ -20,7 +20,7 @@ Let's dive in and start your developer journey on ZKsync! This series requires some initial setup of tools to elevate your development experience building for ZKsync. -Make sure to go through the setup provided in the initial [Getting started](/build/zksync-101) section. +Make sure to go through the setup provided in the initial [Getting started](/build/start-coding/zksync-101) section. Select the framework you want to get started using ZKsync Era with. @@ -49,7 +49,7 @@ Having successfully deployed your first contract on ZKsync, you're well on your a proficient ZKsync developer. To expand your expertise: - **Explore Contract Factories:** Enhance your project by building a contract factory -for the `CrowdfundingCampaign` contract in the [next guide](/build/zksync-101/contract-factory). This will allow you to efficiently +for the `CrowdfundingCampaign` contract in the [next guide](/build/start-coding/zksync-101/contract-factory). This will allow you to efficiently manage multiple crowdfunding campaigns, each with its own unique parameters. - **Dive Deeper into ZKsync Features:** Investigate advanced ZKsync features such as account abstraction, and paymasters. diff --git a/content/00.build/10.zksync-101/20.contract-factory.md b/content/00.build/05.start-coding/10.zksync-101/20.contract-factory.md similarity index 97% rename from content/00.build/10.zksync-101/20.contract-factory.md rename to content/00.build/05.start-coding/10.zksync-101/20.contract-factory.md index 6abd13fa..2e8538ca 100644 --- a/content/00.build/10.zksync-101/20.contract-factory.md +++ b/content/00.build/05.start-coding/10.zksync-101/20.contract-factory.md @@ -56,7 +56,7 @@ off-chain monitoring and interaction. With the contract factory in your ZKsync development arsenal, you're set to elevate your smart contract projects. Here's how you can further your journey: -- **Contract Testing:** Progress to the next guide focused on [testing your contracts](/build/zksync-101/testing). +- **Contract Testing:** Progress to the next guide focused on [testing your contracts](/build/start-coding/zksync-101/testing). Ensuring the reliability and security of your `CrowdfundingCampaign` through comprehensive tests is critical. - **Advanced ZKsync Integrations:** Explore deeper into ZKsync's ecosystem by diff --git a/content/00.build/10.zksync-101/30.testing.md b/content/00.build/05.start-coding/10.zksync-101/30.testing.md similarity index 97% rename from content/00.build/10.zksync-101/30.testing.md rename to content/00.build/05.start-coding/10.zksync-101/30.testing.md index ccae8192..03f6020e 100644 --- a/content/00.build/10.zksync-101/30.testing.md +++ b/content/00.build/05.start-coding/10.zksync-101/30.testing.md @@ -47,7 +47,7 @@ that enhance the testing process. With a solid foundation in contract testing, you're well-equipped to advance your ZKsync development journey. Consider the following steps to further your expertise: -- **Upgradeability**: Dive into the [Upgradeability article](/build/zksync-101/upgrading) focusing on contract upgradeability. +- **Upgradeability**: Dive into the [Upgradeability article](/build/start-coding/zksync-101/upgrading) focusing on contract upgradeability. Learning to make your contracts upgradeable will enable you to update and improve your smart contracts over time without losing state or funds. - **Advanced ZKsync Integrations:** Explore deeper into ZKsync's ecosystem by diff --git a/content/00.build/10.zksync-101/40.upgrading.md b/content/00.build/05.start-coding/10.zksync-101/40.upgrading.md similarity index 97% rename from content/00.build/10.zksync-101/40.upgrading.md rename to content/00.build/05.start-coding/10.zksync-101/40.upgrading.md index d6f992eb..c9a168b8 100644 --- a/content/00.build/10.zksync-101/40.upgrading.md +++ b/content/00.build/05.start-coding/10.zksync-101/40.upgrading.md @@ -46,7 +46,7 @@ functionalities evolve. This approach provides a resilient framework for your dA ## Next Steps -- **Exploring Paymasters:** Continue on to the next guide focused on [using paymasters](/build/zksync-101/paymaster) +- **Exploring Paymasters:** Continue on to the next guide focused on [using paymasters](/build/start-coding/zksync-101/paymaster) with your smart contracts. Paymasters abstract gas payments in transactions, offering new models for transaction fee management and enhancing user experience in dApps. - **Advanced ZKsync Integrations:** Explore deeper into ZKsync's ecosystem by diff --git a/content/00.build/10.zksync-101/50.paymaster.md b/content/00.build/05.start-coding/10.zksync-101/50.paymaster.md similarity index 100% rename from content/00.build/10.zksync-101/50.paymaster.md rename to content/00.build/05.start-coding/10.zksync-101/50.paymaster.md diff --git a/content/00.build/10.zksync-101/_deploy_factory/_foundry_deploy_contract_factory.md b/content/00.build/05.start-coding/10.zksync-101/_deploy_factory/_foundry_deploy_contract_factory.md similarity index 98% rename from content/00.build/10.zksync-101/_deploy_factory/_foundry_deploy_contract_factory.md rename to content/00.build/05.start-coding/10.zksync-101/_deploy_factory/_foundry_deploy_contract_factory.md index 29b1aacf..d1d5f442 100644 --- a/content/00.build/10.zksync-101/_deploy_factory/_foundry_deploy_contract_factory.md +++ b/content/00.build/05.start-coding/10.zksync-101/_deploy_factory/_foundry_deploy_contract_factory.md @@ -13,7 +13,7 @@ cd foundry-contract-factory-quickstart ## Set up your wallet -:display-partial{path="build/zksync-101/_partials/_setup-wallet"} +:display-partial{path="build/start-coding/zksync-101/_partials/_setup-wallet"} --- diff --git a/content/00.build/10.zksync-101/_deploy_factory/_hardhat_deploy_contract_factory.md b/content/00.build/05.start-coding/10.zksync-101/_deploy_factory/_hardhat_deploy_contract_factory.md similarity index 98% rename from content/00.build/10.zksync-101/_deploy_factory/_hardhat_deploy_contract_factory.md rename to content/00.build/05.start-coding/10.zksync-101/_deploy_factory/_hardhat_deploy_contract_factory.md index 178a8860..3be26950 100644 --- a/content/00.build/10.zksync-101/_deploy_factory/_hardhat_deploy_contract_factory.md +++ b/content/00.build/05.start-coding/10.zksync-101/_deploy_factory/_hardhat_deploy_contract_factory.md @@ -10,7 +10,7 @@ cd contract-factory-quickstart ## Set up your wallet -:display-partial{path="build/zksync-101/_partials/_setup-wallet"} +:display-partial{path="build/start-coding/zksync-101/_partials/_setup-wallet"} --- diff --git a/content/00.build/10.zksync-101/_dir.yml b/content/00.build/05.start-coding/10.zksync-101/_dir.yml similarity index 100% rename from content/00.build/10.zksync-101/_dir.yml rename to content/00.build/05.start-coding/10.zksync-101/_dir.yml diff --git a/content/00.build/10.zksync-101/_hello-zksync/_foundry_deploy_contract.md b/content/00.build/05.start-coding/10.zksync-101/_hello-zksync/_foundry_deploy_contract.md similarity index 98% rename from content/00.build/10.zksync-101/_hello-zksync/_foundry_deploy_contract.md rename to content/00.build/05.start-coding/10.zksync-101/_hello-zksync/_foundry_deploy_contract.md index f0677abd..1cfeeb4c 100644 --- a/content/00.build/10.zksync-101/_hello-zksync/_foundry_deploy_contract.md +++ b/content/00.build/05.start-coding/10.zksync-101/_hello-zksync/_foundry_deploy_contract.md @@ -13,7 +13,7 @@ cd hello-zksync-foundry-quickstart ## Set up your wallet -:display-partial{path = "/build/zksync-101/_partials/_setup-wallet"} +:display-partial{path = "/build/start-coding/zksync-101/_partials/_setup-wallet"} ## Compile your first contract diff --git a/content/00.build/10.zksync-101/_hello-zksync/_hardhat_deploy_contract.md b/content/00.build/05.start-coding/10.zksync-101/_hello-zksync/_hardhat_deploy_contract.md similarity index 98% rename from content/00.build/10.zksync-101/_hello-zksync/_hardhat_deploy_contract.md rename to content/00.build/05.start-coding/10.zksync-101/_hello-zksync/_hardhat_deploy_contract.md index 434dd4b9..891ba0bb 100644 --- a/content/00.build/10.zksync-101/_hello-zksync/_hardhat_deploy_contract.md +++ b/content/00.build/05.start-coding/10.zksync-101/_hello-zksync/_hardhat_deploy_contract.md @@ -11,7 +11,7 @@ cd hello-zksync-quickstart ## Set up your wallet -:display-partial{path="build/zksync-101/_partials/_setup-wallet"} +:display-partial{path="build/start-coding/zksync-101/_partials/_setup-wallet"} ## Compile the CrowdfundingCampaign.sol contract diff --git a/content/00.build/10.zksync-101/_partials/_setup-wallet.md b/content/00.build/05.start-coding/10.zksync-101/_partials/_setup-wallet.md similarity index 80% rename from content/00.build/10.zksync-101/_partials/_setup-wallet.md rename to content/00.build/05.start-coding/10.zksync-101/_partials/_setup-wallet.md index 94f55e1b..47e95dcb 100644 --- a/content/00.build/10.zksync-101/_partials/_setup-wallet.md +++ b/content/00.build/05.start-coding/10.zksync-101/_partials/_setup-wallet.md @@ -5,4 +5,4 @@ title: Set up your wallet Deploying contracts on the %%zk_testnet_name%% requires having testnet ETH. If you're working within the local development environment, you can utilize pre-configured rich wallets and skip this step. -For testnet deployments, you should have your wallet funded from the [previous step](/build/zksync-101#fund-your-wallet). +For testnet deployments, you should have your wallet funded from the [previous step](/build/start-coding/zksync-101#fund-your-wallet). diff --git a/content/00.build/10.zksync-101/_paymasters/_approval_paymaster_flow.md b/content/00.build/05.start-coding/10.zksync-101/_paymasters/_approval_paymaster_flow.md similarity index 99% rename from content/00.build/10.zksync-101/_paymasters/_approval_paymaster_flow.md rename to content/00.build/05.start-coding/10.zksync-101/_paymasters/_approval_paymaster_flow.md index 025a0125..93fabb97 100644 --- a/content/00.build/10.zksync-101/_paymasters/_approval_paymaster_flow.md +++ b/content/00.build/05.start-coding/10.zksync-101/_paymasters/_approval_paymaster_flow.md @@ -12,7 +12,7 @@ cd contract-paymaster-quickstart ## Set up your wallet -:display-partial{path = "/build/zksync-101/_partials/_setup-wallet"} +:display-partial{path = "/build/start-coding/zksync-101/_partials/_setup-wallet"} --- diff --git a/content/00.build/10.zksync-101/_paymasters/_general_paymaster_flow.md b/content/00.build/05.start-coding/10.zksync-101/_paymasters/_general_paymaster_flow.md similarity index 99% rename from content/00.build/10.zksync-101/_paymasters/_general_paymaster_flow.md rename to content/00.build/05.start-coding/10.zksync-101/_paymasters/_general_paymaster_flow.md index f338573d..50a9fc74 100644 --- a/content/00.build/10.zksync-101/_paymasters/_general_paymaster_flow.md +++ b/content/00.build/05.start-coding/10.zksync-101/_paymasters/_general_paymaster_flow.md @@ -12,7 +12,7 @@ cd contract-paymaster-quickstart ## Set up your wallet -:display-partial{path = "/build/zksync-101/_partials/_setup-wallet"} +:display-partial{path = "/build/start-coding/zksync-101/_partials/_setup-wallet"} --- diff --git a/content/00.build/10.zksync-101/_testing/_foundry_contract_testing.md b/content/00.build/05.start-coding/10.zksync-101/_testing/_foundry_contract_testing.md similarity index 100% rename from content/00.build/10.zksync-101/_testing/_foundry_contract_testing.md rename to content/00.build/05.start-coding/10.zksync-101/_testing/_foundry_contract_testing.md diff --git a/content/00.build/10.zksync-101/_testing/_hardhat_contract_testing.md b/content/00.build/05.start-coding/10.zksync-101/_testing/_hardhat_contract_testing.md similarity index 98% rename from content/00.build/10.zksync-101/_testing/_hardhat_contract_testing.md rename to content/00.build/05.start-coding/10.zksync-101/_testing/_hardhat_contract_testing.md index 87d2c71e..9fbab211 100644 --- a/content/00.build/10.zksync-101/_testing/_hardhat_contract_testing.md +++ b/content/00.build/05.start-coding/10.zksync-101/_testing/_hardhat_contract_testing.md @@ -17,7 +17,8 @@ While setting up a local development environment was previously optional, testin a more structured setup. We'll use `hardhat-zksync` to run tests against an In-memory node, which operates seamlessly within a separate process for an optimized testing workflow. -If you have not set up your local era node yet, follow the instructions in the [Getting Started](/build/zksync-101#setup-era-local-node-optional) section. +If you have not set up your local era node yet, follow the instructions in the +[Getting Started](/build/start-coding/zksync-101#setup-era-local-node-optional) section. Within the `hardhat.config.ts`, you'll observe the `zksync` flag set to `true` under the `hardhat` network, indicating the integration with ZKsync's testing environment. diff --git a/content/00.build/10.zksync-101/_upgrading/_beacon/_foundry_beacon_contract_upgradability.md b/content/00.build/05.start-coding/10.zksync-101/_upgrading/_beacon/_foundry_beacon_contract_upgradability.md similarity index 100% rename from content/00.build/10.zksync-101/_upgrading/_beacon/_foundry_beacon_contract_upgradability.md rename to content/00.build/05.start-coding/10.zksync-101/_upgrading/_beacon/_foundry_beacon_contract_upgradability.md diff --git a/content/00.build/10.zksync-101/_upgrading/_beacon/_hardhat_beacon_contract_upgradability.md b/content/00.build/05.start-coding/10.zksync-101/_upgrading/_beacon/_hardhat_beacon_contract_upgradability.md similarity index 99% rename from content/00.build/10.zksync-101/_upgrading/_beacon/_hardhat_beacon_contract_upgradability.md rename to content/00.build/05.start-coding/10.zksync-101/_upgrading/_beacon/_hardhat_beacon_contract_upgradability.md index c30fbf9a..05ae1472 100644 --- a/content/00.build/10.zksync-101/_upgrading/_beacon/_hardhat_beacon_contract_upgradability.md +++ b/content/00.build/05.start-coding/10.zksync-101/_upgrading/_beacon/_hardhat_beacon_contract_upgradability.md @@ -15,7 +15,7 @@ If you encounter an error while installing project dependencies using NPM as you ## Set up your wallet -:display-partial{path = "/build/zksync-101/_partials/_setup-wallet"} +:display-partial{path = "/build/start-coding/zksync-101/_partials/_setup-wallet"} --- diff --git a/content/00.build/10.zksync-101/_upgrading/_beacon_proxy_contract_upgradability.md b/content/00.build/05.start-coding/10.zksync-101/_upgrading/_beacon_proxy_contract_upgradability.md similarity index 100% rename from content/00.build/10.zksync-101/_upgrading/_beacon_proxy_contract_upgradability.md rename to content/00.build/05.start-coding/10.zksync-101/_upgrading/_beacon_proxy_contract_upgradability.md diff --git a/content/00.build/10.zksync-101/_upgrading/_transparent/_foundry_transparent_contract_upgradability.md b/content/00.build/05.start-coding/10.zksync-101/_upgrading/_transparent/_foundry_transparent_contract_upgradability.md similarity index 100% rename from content/00.build/10.zksync-101/_upgrading/_transparent/_foundry_transparent_contract_upgradability.md rename to content/00.build/05.start-coding/10.zksync-101/_upgrading/_transparent/_foundry_transparent_contract_upgradability.md diff --git a/content/00.build/10.zksync-101/_upgrading/_transparent/_hardhat_transparent_contract_upgradability.md b/content/00.build/05.start-coding/10.zksync-101/_upgrading/_transparent/_hardhat_transparent_contract_upgradability.md similarity index 99% rename from content/00.build/10.zksync-101/_upgrading/_transparent/_hardhat_transparent_contract_upgradability.md rename to content/00.build/05.start-coding/10.zksync-101/_upgrading/_transparent/_hardhat_transparent_contract_upgradability.md index ef4765dd..2be9c49f 100644 --- a/content/00.build/10.zksync-101/_upgrading/_transparent/_hardhat_transparent_contract_upgradability.md +++ b/content/00.build/05.start-coding/10.zksync-101/_upgrading/_transparent/_hardhat_transparent_contract_upgradability.md @@ -14,7 +14,7 @@ If you encounter an error while installing project dependencies using NPM as you ## Set up your wallet -:display-partial{path = "build/zksync-101/_partials/_setup-wallet"} +:display-partial{path = "build/start-coding/zksync-101/_partials/_setup-wallet"} --- diff --git a/content/00.build/10.zksync-101/_upgrading/_transparent_proxy_contract_upgradability.md b/content/00.build/05.start-coding/10.zksync-101/_upgrading/_transparent_proxy_contract_upgradability.md similarity index 100% rename from content/00.build/10.zksync-101/_upgrading/_transparent_proxy_contract_upgradability.md rename to content/00.build/05.start-coding/10.zksync-101/_upgrading/_transparent_proxy_contract_upgradability.md diff --git a/content/00.build/10.zksync-101/_upgrading/_uups/_foundry_uups_contract_upgradability.md b/content/00.build/05.start-coding/10.zksync-101/_upgrading/_uups/_foundry_uups_contract_upgradability.md similarity index 100% rename from content/00.build/10.zksync-101/_upgrading/_uups/_foundry_uups_contract_upgradability.md rename to content/00.build/05.start-coding/10.zksync-101/_upgrading/_uups/_foundry_uups_contract_upgradability.md diff --git a/content/00.build/10.zksync-101/_upgrading/_uups/_hardhat_uups_contract_upgradability.md b/content/00.build/05.start-coding/10.zksync-101/_upgrading/_uups/_hardhat_uups_contract_upgradability.md similarity index 99% rename from content/00.build/10.zksync-101/_upgrading/_uups/_hardhat_uups_contract_upgradability.md rename to content/00.build/05.start-coding/10.zksync-101/_upgrading/_uups/_hardhat_uups_contract_upgradability.md index 1e83a1c8..cb0a0de0 100644 --- a/content/00.build/10.zksync-101/_upgrading/_uups/_hardhat_uups_contract_upgradability.md +++ b/content/00.build/05.start-coding/10.zksync-101/_upgrading/_uups/_hardhat_uups_contract_upgradability.md @@ -15,7 +15,7 @@ If you encounter an error while installing project dependencies using NPM as you ## Set up your wallet -:display-partial{path="build/zksync-101/_partials/_setup-wallet"} +:display-partial{path="build/start-coding/zksync-101/_partials/_setup-wallet"} --- diff --git a/content/00.build/10.zksync-101/_upgrading/_uups_contract_upgradability.md b/content/00.build/05.start-coding/10.zksync-101/_upgrading/_uups_contract_upgradability.md similarity index 100% rename from content/00.build/10.zksync-101/_upgrading/_uups_contract_upgradability.md rename to content/00.build/05.start-coding/10.zksync-101/_upgrading/_uups_contract_upgradability.md diff --git a/content/00.build/05.start-coding/_dir.yml b/content/00.build/05.start-coding/_dir.yml new file mode 100644 index 00000000..26203c7d --- /dev/null +++ b/content/00.build/05.start-coding/_dir.yml @@ -0,0 +1 @@ +title: Start Coding πŸš€ diff --git a/content/00.build/20.zksync-cli/00.index.md b/content/00.build/20.zksync-cli/00.index.md index 40d827d3..ea85629d 100644 --- a/content/00.build/20.zksync-cli/00.index.md +++ b/content/00.build/20.zksync-cli/00.index.md @@ -3,41 +3,47 @@ title: Getting Started description: Learn how to use the powerful ZKsync CLI tool for local development. --- -The ZKsync Command Line Interface (CLI) is a powerful tool designed to simplify the development and interaction with ZKsync from a command shell. +The ZKsync CLI is a powerful tool designed to simplify the setup, development, testing, and deployment of contracts on ZKsync. +It also provides a way to scaffold dApps using templates using various frontend and web3 libraries. +ZKsync CLI is published on npm as [`zksync-cli`](https://www.npmjs.com/package/zksync-cli). +Commands are invoked using `zksync-cli` in the terminal. -## Usage +## Dependencies -You can run commands locally without installation using the following command: `npx zksync-cli`. For example: `npx zksync-cli dev start`. +To install ZKsync CLI on your local system, you will need Node.js. +ZKsync CLI requires Node.js to run commands on your local environment. -### Install zksync-cli +[Download and install Node.js](https://nodejs.org/en/download) which will include the `npm` and `npx` commands. +You can execute ZKsync CLI commands without having to install the package using the `npx` command. +Our guides will assume you to install the ZKsync CLI globally using `npm install`. -You can alternatively install the CLI globally using the npm package manager: +### Optional dependencies -```bash +If you wish to use ZKsync CLI to manage and run a ZKsync environment locally such as ZKsync nodes, +Block Explorer, Wallet, and Bridge, you will need to install Docker. +The Docker Desktop provides an easy to use application to manage Docker images and containers. + +[Download and install Docker](https://www.docker.com/get-started/) which will include a desktop GUI +to manage Docker containers and images. + +## Install ZKsync CLI +To install the ZKsync CLI, open up a terminal window and run the following command: + +```sh npm install -g zksync-cli ``` -::callout{icon="i-heroicons-light-bulb" color="blue"} -If you go the route of installing the zksync-cli package locally, we recommend using the global option. -:: - -### Update zksync-cli +### Update ZKsync CLI -If you installed `zksync-cli` via the npm package manager, you can update with the following: +To update your installed package of ZKsync CLI, run the following command: -```bash +```sh npm update -g zksync-cli ``` ## Available Commands -- [`dev`](zksync-cli/zksync-cli-dev): Start a local development environment with ZKsync and Ethereum nodes. -- [`create`](zksync-cli/zksync-cli-create): Scaffold new projects using templates for frontend, contracts, and scripting. -- [`contract`](zksync-cli/zksync-cli-contract): Read and write data to ZKsync contracts without building UI. -- [`transaction`](zksync-cli/zksync-cli-transaction): Fetch and display detailed information about a specific transaction. -- [`wallet`](zksync-cli/zksync-cli-wallet): Manage ZKsync wallet assets, including transfers and balance checks. -- [`bridge`](zksync-cli/zksync-cli-bridge): Perform deposits and withdrawals between Ethereum and ZKsync. -- [`config chains`](zksync-cli/zksync-cli-config-chains): Add or edit custom chains for flexible testing and development. +To learn more about the available commands in ZKsync CLI, see the [CLI reference](/build/zksync-cli/reference). ## Further Assistance diff --git a/content/00.build/20.zksync-cli/05.reading-transaction-data.md b/content/00.build/20.zksync-cli/05.reading-transaction-data.md new file mode 100644 index 00000000..13657d3a --- /dev/null +++ b/content/00.build/20.zksync-cli/05.reading-transaction-data.md @@ -0,0 +1,80 @@ +--- +title: Reading transaction data +description: Use ZKsync CLI to easily read transaction data from the command line +--- + +You can use the ZKsync CLI to fetch and display detailed information for a transaction. +It can be used to check the status, amounts transferred, fees, method signatures, and arguments of transactions. + +```sh +zksync-cli transaction info +``` + +If you do not pass in any options to the command, the CLI prompts you to select the chain and transaction hash. + +```sh +? Chain to use ZKsync Sepolia Testnet +? Transaction hash 0x7f82dbf93281930ee01644d01a84b3f13df51d0082370298d353982f008f09e1 +``` + +The CLI returns the transaction data along with the method arguments and additional details. + +```sh +──────────────────── Main info ──────────────────── +Transaction hash: 0x7f82dbf93281930ee01644d01a84b3f13df51d0082370298d353982f008f09e1 +Status: completed +From: 0xfAa77e3314c82cD5097B80Ab42C6A3749f33dEE6 +To: 0x927488F48ffbc32112F1fF721759649A89721F8F +Value: 0 ETH +Fee: 0.00000220235 ETH | Initial: 0.0000520258 ETH Refunded: 0.00322339725 ETH +Method: transfer(address to, uint256 amount) returns (bool) 0xa9059cbb + +───────────────── Method arguments ───────────────── +[1] to (address): 0xfAa77e3314c82cD5097B80Ab42C6A3749f33dEE6 +[2] amount (uint256): 1 + +───────────────────── Details ───────────────────── +Date: 7/23/2024, 6:58:53 PM (15 hours ago) +Block: #3515643 +Nonce: 3 +``` + +## --abi + +When ZKsync CLI reads a transaction that includes interaction with a smart contract's method, +it first tries to fetch contract verification data from the server. +If the contract is not verified, the CLI queries the [open signature](https://www.4byte.directory/) +database to get the signature of the transaction method. +If the CLI fails to find a matching method signature, the transaction data will be displayed as a hex string. + +You can manually pass the contract ABI data manually using the `--abi` option to decode the transaction's input data. + +```sh +zksync-cli transaction info --abi "./Greeter.json" +``` + +## --full + +The `--full` option will include additional details of the transaction which include the transaction status on L1. + +To see an example of the full data you receive with the `--full` option: + +```sh +zksync-cli transaction info \ +--chain "zksync-sepolia" \ +--transaction "0x6fe7bcdbef11776095c7dd4283a54f51e60c0fe7cfc784fa52b9dcb8f2270f9f" \ +--full +``` + +## --raw + +The `--raw` option returns the transaction data as a raw JSON response. + +To see an example of the raw JSON data: + +```sh +zksync-cli transaction info \ +--chain "zksync-sepolia" \ +--transaction "0x6fe7bcdbef11776095c7dd4283a54f51e60c0fe7cfc784fa52b9dcb8f2270f9f" \ +--raw +``` diff --git a/content/00.build/20.zksync-cli/10.wallet-actions.md b/content/00.build/20.zksync-cli/10.wallet-actions.md new file mode 100644 index 00000000..71995ec9 --- /dev/null +++ b/content/00.build/20.zksync-cli/10.wallet-actions.md @@ -0,0 +1,71 @@ +--- +title: Wallet actions +description: Use ZKsync CLI to interact with your wallet +--- + +The ZKsync CLI provides basic commands to interact with your wallet. +You can review your balance of ETH or ERC20 token as well as transfer ETH and ERC20 tokens between L2 addresses. + +## Balance + +You can review your ETH balance using the `balance` sub-command: + +```sh +zksync-cli wallet balance +``` + +The CLI prompts for which chain to use as well as the account address. +It then returns the balance of that account address on the selected chain. + +```sh +? Chain to use ZKsync Sepolia Testnet +? Account address 0xfAa77e3314c82cD5097B80Ab42C6A3749f33dEE6 + +ZKsync Sepolia Testnet Balance: 0.099987931675 ETH (Ether) +``` + +### ERC20 token balance + +To display the balance of an ERC20 token for an account address, use the `--token` option with the address of the ERC20 smart contract. + +```sh +zksync-cli wallet balance \ +--token 0x927488F48ffbc32112F1fF721759649A89721F8F +``` + +It returns the balance for the account with the display of the ERC20 token name. + +```sh +? Chain to use ZKsync Sepolia Testnet +? Account address 0xfAa77e3314c82cD5097B80Ab42C6A3749f33dEE6 + +ZKsync Sepolia Testnet Balance: 0.000000000000000001 Crown (Crown) +``` + +## Transfer + +You can transfer ETH and ERC20 tokens using the `transfer` sub-command. +Use the `--token` option with the address of the token smart contract to transfer ERC20 tokens. + +```sh +zksync-cli wallet transfer +``` + +This command requires the chain, the amount to transfer, the private key of the sender, and the recipient address. + +```sh +? Chain to use ZKsync Mainnet +? Amount to transfer 0.000001 +? Private key of the sender [hidden] +? Recipient address on L2 0xfAa77e3314c82cD5097B80Ab42C6A3749f33dEE6 +``` + +On a successful transaction, the CLI returns the details of the transfer and the sender's balance. + +```sh +Transfer sent: + Transaction hash: 0x1692c703f7204a7e36581187890701b592b3c6f1e55b7ad55563a9ae2389fb56 + Transaction link: https://explorer.zksync.io/tx/0x1692c703f7204a7e36581187890701b592b3c6f1e55b7ad55563a9ae2389fb56 + +Sender L2 balance after transaction: 0.013199184619193711 ETH (Ether) +``` diff --git a/content/00.build/20.zksync-cli/10.zksync-cli-dev.md b/content/00.build/20.zksync-cli/10.zksync-cli-dev.md deleted file mode 100644 index 87f9fb57..00000000 --- a/content/00.build/20.zksync-cli/10.zksync-cli-dev.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -title: zksync-cli dev -description: Manage a local node with zksync-cli. ---- - -Utilize `zksync-cli` to effortlessly initiate a local development environment. -Using the command, `zksync-cli dev start`, you can spin up local ZKsync and Ethereum nodes, along with Block Explorer, Wallet, and Bridge -for a seamless development experience. - -## Prerequisites - -Before beginning, ensure you have installed: - -- [Node.js](https://nodejs.org) v18+ -- [Git](https://git-scm.com/downloads) -- [Docker](https://www.docker.com/get-started/) - -## Starting and Stopping Nodes - -- **Start**: `zksync-cli dev start` initiates your local environment. On the first run, it prompts to select a node and additional modules. -- **Stop**: `zksync-cli dev stop` terminates the local environment. Use `zksync-cli dev stop [module name]` to stop specific modules. -- **Restart**: `zksync-cli dev restart` or `zksync-cli dev restart [module name]` restarts your environment or specific modules. - -## Configuring Your Environment - -- `zksync-cli dev config` allows the selection of nodes and additional modules like block explorer and bridge. -Run modules such as Block Explorer against an already running node by adding a new chain. - -## Managing Modules - -- `zksync-cli dev modules` lists all installed modules, providing a clear overview of your environment's components. - -## Viewing Logs - -- `zksync-cli dev logs` displays logs for all active modules, essential for monitoring and debugging. - -## Cleaning Modules - -- `zksync-cli dev clean` removes all module data from your computer. For specific modules, use `zksync-cli dev clean [module name]`. - -## Updating Modules - -- `zksync-cli dev update [module name]` updates individual modules, ensuring you're running the latest versions. - -## Troubleshooting - -If modules malfunction, e.g., failing to start: - -1. Use `zksync-cli dev stop` to cease all operations. -2. Reinstall the problematic module with `zksync-cli dev clean [module name]`. -3. Restart with `zksync-cli dev start`. Check Docker container logs for detailed errors, accessible through Docker Desktop. -4. Persisting issues? Please report them in our [GitHub discussions](%%zk_git_repo_zksync-developers%%/discussions/new?category=general&title=[zksync-cli]%20). diff --git a/content/00.build/20.zksync-cli/20.bridging.md b/content/00.build/20.zksync-cli/20.bridging.md new file mode 100644 index 00000000..eb7a0745 --- /dev/null +++ b/content/00.build/20.zksync-cli/20.bridging.md @@ -0,0 +1,139 @@ +--- +title: Bridging +description: Use ZKsync CLI to bridge between L1 and L2 chains +--- + +The ZKsync CLI provides bridging commands to deposit and withdraw ETH and ERC20 tokens between L1 and L2 chains. + +## Deposit + +To deposit ETH from L1 to L2, use the `bridge` sub-command. +You can pass all the required options as flags for the command, otherwise the CLI will prompt for the required values. + +```sh +zksync-cli bridge deposit +``` + +The CLI requires the L2 chain, the amount to deposit, the private key and the recipient address on the L2. +The recipient address will default to the public address of the private key you provide. + +```sh +? Chain to use ZKsync Sepolia Testnet +? Amount to deposit 0.005 +? Private key of the sender [hidden] +? Recipient address on L2 0xfAa77e3314c82cD5097B80Ab42C6A3749f33dEE6 +``` + +A deposit summary will display and the transaction will take a moment to process before it further displays the successful transaction details. + +```sh +Deposit: + From: 0xfAa77e3314c82cD5097B80Ab42C6A3749f33dEE6 (Ethereum Sepolia Testnet) + To: 0xfAa77e3314c82cD5097B80Ab42C6A3749f33dEE6 (ZKsync Sepolia Testnet) + Amount: 0.005 ETH (Ether) + +Deposit sent: + Transaction hash: 0x68a0f2b08ca053faa37c1ea51a562ac7a119271555fc829e6db74d82d2f7a2b7 + Transaction link: https://sepolia.etherscan.io/tx/0x68a0f2b08ca053faa37c1ea51a562ac7a119271555fc829e6db74d82d2f7a2b7 + +Sender L1 balance after transaction: 0.041260124570176254 ETH (Ether) +``` + +## Withdraw + +You can use the `withdraw` sub-command to transfer ETH or ERC20 tokens from L2 to L1. + +```sh +zksync-cli bridge withdraw +``` + +The CLI requires the L2 chain, the amount to deposit, the private key and the recipient address on the L1. +The recipient address will default to the public address of the private key you provide. + +```sh +? Chain to use ZKsync Sepolia Testnet +? Amount to withdraw 0.005 +? Private key of the sender [hidden] +? Recipient address on L1 0xfAa77e3314c82cD5097B80Ab42C6A3749f33dEE6 +``` + +A deposit summary will display and the transaction will take a moment to process before it further displays the successful transaction details. + +```sh +Withdraw: + From: 0xfAa77e3314c82cD5097B80Ab42C6A3749f33dEE6 (ZKsync Sepolia Testnet) + To: 0xfAa77e3314c82cD5097B80Ab42C6A3749f33dEE6 (Ethereum Sepolia Testnet) + Amount: 0.005 ETH (Ether) + +Withdraw sent: + Transaction hash: 0xa50f8c1ffd0d7cdbd7a623f8dd63ee1731e6c4e393d8b7ed954bb19285b369f3 + Transaction link: https://sepolia.explorer.zksync.io/tx/0xa50f8c1ffd0d7cdbd7a623f8dd63ee1731e6c4e393d8b7ed954bb19285b369f3 + +Sender L2 balance after transaction: 0.1003136843418423 ETH (Ether) +``` + +## Withdraw-Finalize + +Any withdrawals may require a withdraw-finalize dependent upon the rules of the L2. +ZKsync Era has a [24 hour delay](/build/resources/withdrawal-delay) before you can finalize your withdrawal on L1. +The `withdraw-finalize` sub-command finalizes the transaction with the private key of the sender. + +```sh +zksync-cli bridge withdraw-finalize +``` + +The CLI asks for the chain, the L2 withdrawal transaction hash and the private key of the sender to initiate the finalization of the withdrawal. + +```sh +? Chain to use ZKsync Sepolia Testnet +? L2 withdrawal transaction hash to finalize 0xa50f8c1ffd0d7cdbd7a623f8dd63ee1731e6c4e393d8b7ed954bb19285b369f3 +? Private key of the sender [hidden] +``` + +The CLI then displays the details of the withdrawal to finalize and check on the status of the transaction. + +```sh +Withdraw finalize: + From chain: ZKsync Sepolia Testnet + To chain: Ethereum Sepolia Testnet + Withdrawal transaction (L2): 0xa50f8c1ffd0d7cdbd7a623f8dd63ee1731e6c4e393d8b7ed954bb19285b369f3 + Finalizer address (L1): 0xfAa77e3314c82cD5097B80Ab42C6A3749f33dEE6 + +Checking status of the transaction... +``` + +If the transaction is available to finalize, it will display a successful message. + +```sh +Transaction is ready to be finalized + +Sending finalization transaction... + +Withdrawal finalized: + Finalization transaction hash: 0x9877c291dbfa232d01ac1daa7d72cbda727ccc0d893f5851464d20db9bd0db2a + Transaction link: https://sepolia.etherscan.io/tx/0x9877c291dbfa232d01ac1daa7d72cbda727ccc0d893f5851464d20db9bd0db2a + +Waiting for finalization transaction to be mined... + Finalization transaction was mined in block 6375446 + +Sender L1 balance after transaction: 0.04570351455452712 ETH (Ether) +``` + +If the transaction is still waiting to be processed fully from L2 to L1, an error will display. + +```sh +Checking status of the transaction... +β“˜ +Transaction is still being processed on ZKsync Sepolia Testnet, please try again when the ethExecuteTxHash has been computed +L2 Transaction Details: { + "ethCommitTxHash": null, + "ethExecuteTxHash": null, + "ethProveTxHash": null, + "fee": "0xa77644aa700", + "gasPerPubdata": "0xc350", + "initiatorAddress": "0xfaa77e3314c82cd5097b80ab42c6a3749f33dee6", + "isL1Originated": false, + "receivedAt": "2024-07-24T18:06:57.307Z", + "status": "included" +} +``` diff --git a/content/00.build/20.zksync-cli/30.interact-with-contracts.md b/content/00.build/20.zksync-cli/30.interact-with-contracts.md new file mode 100644 index 00000000..e034180a --- /dev/null +++ b/content/00.build/20.zksync-cli/30.interact-with-contracts.md @@ -0,0 +1,208 @@ +--- +title: Interact with contracts +description: Interact with smart contracts using ZKsync CLI +--- + +You can interact with smart contracts on ZKsync using the ZKsync CLI. +These commands automate tasks such as method verification, ABI handling, output decoding and proxy contract processing. + +## Read example + +Run the following command without any options: + +```sh +zksync-cli contract read +``` + +ZKsync CLI prompts with an interactive list of questions to define the options. + +```sh +? Chain to use: ZKsync Sepolia Testnet +? Contract address: 0x927488F48ffbc32112F1fF721759649A89721F8F +``` + +Next, ZKsync CLI will prompt to select the contract method to call. +If the smart contract is verified on ZKsync, the CLI returns a list of the smart contract's available methods. + +```sh +? Contract method to call (Use arrow keys) + ──────────────── Provided contract ──────────────── +❯ allowance(address owner, address spender) view returns (uint256) + balanceOf(address account) view returns (uint256) + decimals() view returns (uint8) + name() view returns (string) + symbol() view returns (string) + totalSupply() view returns (uint256) + ─────────────────────────────────────────────────── + Type method manually +``` + +Otherwise the CLI will prompt you to enter the method signature manually. + +```sh +? Enter method to call balanceOf(address account) +``` + +You can pass the ABI file of the smart contract using the `--abi` option. +This decodes the contract methods and infer the output type of the selected method. + +Once you select a method to call, the CLI prompts you to enter the method arguments, one by one: + +```sh +? Provide method arguments: +? [1/1] account (address) 0xfAa77e3314c82cD5097B80Ab42C6A3749f33dEE6 +``` + +If you selected a verified method from the list of the smart contract's methods, +you will see a response in it's original encoded form along with the decoded method response. + +```sh +βœ” Method response (raw): 0x0000000000000000000000000000000000000000000000000000000000000000 +βœ” Decoded method response: 0 +``` + +If you entered the smart contract's method manually, the CLI will prompt you for the method's **output type** to decode the response. +You can skip this step by submitting an empty response. + +```sh +βœ” Method response (raw): 0x0000000000000000000000000000000000000000000000000000000000000000 +Provide output types to decode the response (optional) +? Output types uint256 +βœ” Decoded method response: 0 +``` + +To skip the decode method response step, you can use the `--decode-skip` option. + +::callout{icon="i-heroicons-information-circle" color="blue"} +**TIP:** After running a command without options, you will see a full command with all the options defined that you can +copy and use later to quickly run the same command again. +:: + +For example, the constructed command for the above: + +```sh +npx zksync-cli contract read --chain "zksync-sepolia" --contract "0x927488F48ffbc32112F1fF721759649A89721F8F" --method "balanceOf(address account)" --args "0xfAa77e3314c82cD5097B80Ab42C6A3749f33dEE6" --output "uint256" +``` + +## Write example + +Run the following command without any options: + +```sh +zksync-cli contract write +``` + +ZKsync CLI prompts with an interactive list of questions to define the options. + +```sh +? Chain to use: ZKsync Sepolia Testnet +? Contract address: 0x927488F48ffbc32112F1fF721759649A89721F8F +``` + +Next, ZKsync CLI prompts to select the contract method to call. +If the smart contract is verified on ZKsync, the CLI returns a list of the smart contract's available methods. + +```sh +? Contract method to call + ──────────────── Provided contract ──────────────── + approve(address spender, uint256 amount) + burn(uint256 amount) + burnFrom(address account, uint256 amount) + decreaseAllowance(address spender, uint256 subtractedValue) + increaseAllowance(address spender, uint256 addedValue) + mint(address _to, uint256 _amount) +❯ transfer(address to, uint256 amount) + transferFrom(address from, address to, uint256 amount) + ─────────────────────────────────────────────────── + Type method manually +``` + +Otherwise the CLI will prompt you to enter the method signature manually. + +```sh +? Enter method to call transfer(address, uint256) +``` + +You can pass the ABI file of the smart contract using the `--abi` option. +This will decode the contract methods and infer the output type of the selected method. + +Once you select a method to call, the CLI prompts you to enter the method arguments, one by one: + +```sh +? Provide method arguments: +? [1/2] to (address) 0xfAa77e3314c82cD5097B80Ab42C6A3749f33dEE6 +? [2/2] amount (uint256) 1 +``` + +Next, the CLI prompts for the private key of your wallet to sign the transaction. + +```sh +? Private key of the wallet to sign transaction ****** +``` + +When submitted a contract call is be made and a transaction hash will be returned. + +```sh +βœ” Transaction submitted. Transaction hash: 0x7f82dbf93281930ee01644d01a84b3f13df51d0082370298d353982f008f09e1 +βœ” Transaction processed successfully. Transaction link: https://sepolia.explorer.zksync.io/tx/0x7f82dbf93281930ee01644d01a84b3f13df51d0082370298d353982f008f09e1 +``` + +The fully constructed command for the above actions: + +```sh +npx zksync-cli contract write --chain "zksync-sepolia" --contract "0x927488F48ffbc32112F1fF721759649A89721F8F" --method "transfer(address to, uint256 amount)" --args "0xfAa77e3314c82cD5097B80Ab42C6A3749f33dEE6" "1" +``` + +## Encode example + +You can encode the contract method signature and arguments into raw calldata. +This can be helpful for debugging or unit testing with lower-level libraries. + +To encode a method with arguments, run the CLI command `zksync-cli contract encode`. +The CLI then prompts for the method to encode. + +```sh +? Enter method to encode transfer(address, uint256) +``` + +Next, the CLI will ask for the arguments to provide for the method. + +```sh +? Provide method arguments: +? [1/2] address 0xfAa77e3314c82cD5097B80Ab42C6A3749f33dEE6 +? [2/2] uint256 1 +``` + +The ZKsync CLI then returns the encoded data for the method with the arguments. + +```sh +βœ” Encoded data: 0xa9059cbb000000000000000000000000faa77e3314c82cd5097b80ab42c6a3749f33dee60000000000000000000000000000000000000000000000000000000000000001 +``` + +## --abi + +If you are interacting with a smart contract that is not verified publicly, you can specify a local ABI file with the `--abi` option. +Your ABI data must be in a JSON format or a contract artifact from compilation. + +```sh +zksync-cli contract read --abi "./Greeter.json" +``` + +Providing an ABI for a smart contract will allow the CLI to provide the decoded list of methods to interact with as well as decode the response. + +## --from + +You can specify another address to execute the transaction with the `--from` option. +This is useful when you need to call a method that expects a specific address as `msg.sender`. + +```sh +zksync-cli contract read --from "0xa1cf087DB965Ab02Fb3CFaCe1f5c63935815f044" +``` + +## --value + +To send ETH along with your method call using ZKsync CLI, you can pass a string value with the `--value` option. + +```sh +zksync-cli contract write --value "0.1" +``` diff --git a/content/00.build/20.zksync-cli/30.zksync-cli-contract.md b/content/00.build/20.zksync-cli/30.zksync-cli-contract.md deleted file mode 100644 index 449e890a..00000000 --- a/content/00.build/20.zksync-cli/30.zksync-cli-contract.md +++ /dev/null @@ -1,245 +0,0 @@ ---- -title: zksync-cli contract -description: Interact with contracts using the zksync-cli contract command. ---- - -The `zksync-cli contract` command comes with actions to read, write and encode smart contracts on ZKsync. -These commands automate tasks such as method verification, ABI handling, output decoding, and proxy contract processing. - -::callout{icon="i-heroicons-light-bulb" color="blue"} -After running a command with prompts you will see a full command with all the options that you can copy -and use later to quickly run the same command again. -:: - -## Contract Read - -The `zksync-cli contract read` command executes read-only methods on contracts, like checking ERC-20 balances or contract states. - -### Read Options - -You do not need to specify options below, you will be prompted to enter them if they are not specified. - -- `--chain <chain-name>`: Select the chain to use (e.g., `zksync-mainnet`, `zksync-sepolia`). -- `--rpc <url>`: Provide RPC URL instead of selecting a chain -- `--contract <address>`: Specify contract's address -- `--method <method-signature>`: Defines the contract method to interact with -- `--arguments <method-arguments...>`: Pass arguments to the contract method -- `--data <0x-transaction-data>`: Instead of specifying the method and arguments, you can pass the raw transaction data -- `--outputTypes <output-types...>`: Specifies output types for decoding -- `--from <address>`: Call method on behalf of specified address -- `--abi <path>`: Path to local ABI file or contract artifact -- `--decode-skip`: Skips prompting for output types and decoding the response -- `--show-info`: Displays transaction request information (e.g. encoded transaction data) - -### Basic read example - -```bash -zksync-cli contract read -``` - -1. You will be prompted to select a chain, contract address, and method. - - ```bash - ? Chain to use: %%zk_testnet_name%% - ? Contract address: 0x45E6dC995113fd3d1A3b1964493105B9AA9a9A42 - ``` - -1. Next you need to select a **method (function) to call**. - - - In case your contract is verified it will automatically identify the ABI: - - ```bash - ? Contract method to call - ────────── Provided contract ────────── - ❯ balanceOf(address account) view returns (uint256) - decimals() pure returns (uint8) - name() pure returns (string) - symbol() pure returns (string) - totalSupply() view returns (uint256) - ─────────────────────────────────────── - Type method manually - ``` - - - Otherwise you'll have to enter method signature manually. - - ```bash - ? Enter method to call: balanceOf(address) - ``` - - - Alternatively, you can specify the ABI file manually using the `--abi` option. [See example](#using-a-local-abi-file) - -1. You will be prompted to enter **arguments** for the method, one by one. - - ```bash - ? Provide method arguments: - ? [1/1] account (address): 0xa1cf087DB965Ab02Fb3CFaCe1f5c63935815f044 - ``` - - When submitted a contract call will be made and you'll see the response in it's original encoded form. - - ```bash - βœ” Method response (raw): 0x000000000000000000000000000000000000000000010508e606548a9e5d2000 - ``` - -1. you will be asked the **method output** type to decode the response. -You can skip this step by submitting empty response or completely skip it by passing `--decode-skip` option. - - ```bash - ? Output types: uint256 - βœ” Decoded method response: 1232701801010000000000000 - ``` - -### Running read on behalf of another address - -You can specify the `--from` option to run the method on behalf of another address. -This is useful when you need to call a method that expects a specific address as `msg.sender`. - -```bash -zksync-cli contract read \ - --from "0xa1cf087DB965Ab02Fb3CFaCe1f5c63935815f044" -``` - -## Contract Write - -The `zksync-cli contract write` command performs write operations on smart contracts. -It enables sending transactions that alter the state of a contract, such as transferring tokens or changing ownership. - -### Write Options - -You do not need to specify options below, you will be prompted to enter them if they are not specified. - -- `--chain <chain-name>`: Select the chain to use -- `--rpc <url>`: Provide RPC URL instead of selecting a chain -- `--contract <address>`: Specify contract's address -- `--method <method-signature>`: Defines the contract method to interact with -- `--arguments <method-arguments...>`: Pass arguments to the contract method -- `--value <ether-amount>`: Ether amount to send with the transaction (e.g. 0.01) -- `--private-key <wallet-private-key>`: Private key of the wallet to use to sign the transaction -- `--data <0x-transaction-data>`: Instead of specifying the method and arguments, you can pass the raw transaction data -- `--abi <path>`: Path to local ABI file or contract artifact -- `--show-info`: Displays transaction request information (e.g. encoded transaction data) - -### Basic write example - -```bash -zksync-cli contract write -``` - -1. You will be prompted to select a chain, contract address, and method. - - ```bash - - ? Chain to use: %%zk_testnet_name%% - ? Contract address: 0x45E6dC995113fd3d1A3b1964493105B9AA9a9A42 - ``` - -1. Select a **method (function) to call**. - - - In case your contract is verified it will automatically identify the ABI: - - ```bash - ? Contract method to call - ────────── Provided contract ────────── - ❯ approve(address spender, uint256 amount) returns (bool) - transfer(address to, uint256 amount) returns (bool) - ─────────────────────────────────────── - Type method manually - ``` - - - Otherwise you'll have to enter method signature manually, for example `transfer(address,uint256)`. - - ```bash - ? Enter method to call: transfer(address,uint256) - ``` - - - Alternatively, you can specify the ABI file manually using the `--abi` option. [See example](#using-a-local-abi-file) - -1. You will be prompted to enter **arguments** for the method, one by one. - - ```bash - ? Provide method arguments: - ? [1/2] to (address): 0xa1cf087DB965Ab02Fb3CFaCe1f5c63935815f044 - ? [2/2] amount (uint256): 1 - ``` - -1. provide private key of the wallet to use to sign the transaction. - - ```bash - ? Private key of the wallet to sign transaction: ***** - ``` - -When submitted a contract call will be made and you'll see the transaction hash. - -```bash -βœ” Transaction submitted. Transaction hash: 0xa83ad7e8932e18cdc57d3892040505a50d560a56fa507cabcd4180e9e5898bec -``` - -## Encode - -The `zksync-cli contract encode` command will get calldata (e.g. 0x1234) from contract method signature and arguments. - -### Encode options - -- `--method <contractMethod(arguments)>`: Contract method to interact with -- `--args, --arguments <arguments...>`: Arguments -- `--abi <path/to/abi>`: Contract artifact or ABI file location. - -### Basic encode example - -```bash -zksync-cli contract encode -``` - -1. Select a **method (function) to encode**. - - - Enter method signature manually, for example `transfer(address,uint256)`. - - ```bash - ? Enter method to call: transfer(address,uint256) - ``` - - - Alternatively, you can specify the ABI file using the `--abi` option. [See example](#using-a-local-abi-file) - - ```bash - ? Contract method to call - ────────── Provided contract ────────── - ❯ approve(address spender, uint256 amount) returns (bool) - transfer(address to, uint256 amount) returns (bool) - ─────────────────────────────────────── - Type method manually - ``` - -1. Enter the **arguments** for the method, one by one. - - ```bash - ? Provide method arguments: - ? [1/2] to (address): 0xa1cf087DB965Ab02Fb3CFaCe1f5c63935815f044 - ? [2/2] amount (uint256): 1 - ``` - -When finished you will see the encoded data. - -```bash -βœ” Encoded data: 0xa41368620000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000c48656c6c6f20776f726c64210000000000000000000000000000000000000000 -``` - -## Using a local ABI file - -You can specify a local ABI file using the `--abi` option. -It should be a JSON file with either ABI data (array) or contract artifact which you get after compiling your contracts. - -```bash -zksync-cli contract read \ - --abi "./Greeter.json" -``` - -You will be prompted to select a method (function): - -```bash - ────────── Provided contract ────────── -❯ greet() view returns (string) - ─────────────────────────────────────── - Type method manually -``` - -Response will be decoded automatically according to the ABI file. diff --git a/content/00.build/20.zksync-cli/35.creating-projects.md b/content/00.build/20.zksync-cli/35.creating-projects.md new file mode 100644 index 00000000..3948fc43 --- /dev/null +++ b/content/00.build/20.zksync-cli/35.creating-projects.md @@ -0,0 +1,83 @@ +--- +title: Creating projects +description: Quickly scaffold new projects using templates with ZKsync CLI create +--- + +The ZKsync CLI provides a helpful command to scaffold a project to develop smart contracts, dApps, and scripts for ZKsync. +The `create` command provides many templates to allow you to quickly start a project using +various available libraries and frameworks like Solidity, Vyper, Ethers, and Hardhat to name a few. + +## Create a new project + +To quickly setup a brand new project, navigate to a directory where you want to set up a new folder for your project. +In this example we will create a project to build smart contracts. +Run the following command: + +```sh +zksync-cli create +``` + +The CLI prompts you with several questions to determine what template to setup for the new project. +A template will download and the dependencies will install using the selected package manager. + +```sh +? Enter a folder name for your project: example-project +? What type of project do you want to create? Contracts +? Ethereum framework Ethers v6 +? Template Hardhat + Solidity +? Private key of the wallet responsible for deploying contracts (optional) +? Package manager npm + +Setting up template in /Users/sf/scratch/playground/example-project... +βœ” Cloned template +βœ” Environment variables set up +β ™ Installing dependencies with npm... This may take a couple minutes. +``` + +Upon a successful install, the CLI will return a success message with instructions on how to navigate to your project along common commands to use. + +```sh +βœ” Dependencies installed + +πŸŽ‰ All set up! πŸŽ‰ + +-------------------------- + +Navigate to your project: cd example-project + +Directory Overview: + - Contracts: /contracts + - Deployment Scripts: /deploy + +Commands: + - Compile your contracts: npm run compile + - Deploy your contract: npm run deploy + - Tip: You can use the --network option to specify the network to deploy to. + +Further Reading: + - Check out the README file in the project location for more details: example-project/README.md + +-------------------------- +``` + +Navigate into your project with the command provided from the CLI. + +```sh +cd example-project +``` + +If you are using VSCode for development, you can use the VSCode CLI to launch from the command line. +Depending on your environment, you may need to pre-install some requirements before you can run the VSCode CLI. +For more information, see the section +[Launching from command line](https://code.visualstudio.com/docs/editor/command-line#_launching-from-command-line) +from Visual Studio Code's Command Line Interface (CLI). + +```sh +code . +``` + +## Next steps + +You have successfully scaffolded a new project to start developing on ZKsync! +Check out the [Community Code](https://code.zksync.io) website to find a +collection of tutorials and guides to further your knowledge in developing on ZKsync. diff --git a/content/00.build/20.zksync-cli/40.running-a-node.md b/content/00.build/20.zksync-cli/40.running-a-node.md new file mode 100644 index 00000000..fc746fac --- /dev/null +++ b/content/00.build/20.zksync-cli/40.running-a-node.md @@ -0,0 +1,94 @@ +--- +title: Running a node +description: Guide to running ZKsync nodes locally using the zksync-cli for seamless local development. +--- + +ZKsync CLI provides a powerful `dev` command to spin up and manage ZKsync and Ethereum nodes along with +Block Explorer, Wallet, and Bridge apps for a seamless local development experience. + +## Prerequisites + +You will need [Docker](https://www.docker.com) to setup ZKsync nodes on your local machine. +[Download and install Docker](https://www.docker.com/get-started/) which will install the necessary tools for the `dev` command to work. + +Once installed, ensure that the Docker program is running on your machine, otherwise the `dev` command may error. +Check to make sure that the Docker Desktop is running anytime you restart your machine. + +## Dev modules + +The `dev` command interacts with installed modules to manage and run systems. +To view the available modules that come with ZKsync CLI, run the following command: + +```sh +zksync-cli dev modules +``` + +## Configuring `dev` + +When you run the `dev start` sub-command for the first time, the CLI prompts you to select a node type and additional modules to run as default. +You can also configure this with the `dev config` sub-command to set the default node type and modules to run. + +```sh +zksync-cli dev config +``` + +## Running modules + +To start the modules, run the `zksync-cli dev start` sub-command. +If you are running `dev start` for the first time, it will prompt you to select which modules to start. +The modules will download the required packages on the first run. Subsequent starts do not need to download anything additional. + +The first `start` may take several minutes as it will need to download the necessary packages. +The CLI displays the progress and, upon successful download and start, it will return a summary of the started modules and the available ports. + +```sh +In memory node started v0.1.0-alpha.25: + - ZKsync Node (L2): + - Chain ID: 260 + - RPC URL: http://127.0.0.1:8011 + - Rich accounts: https://docs.zksync.io/build/test-and-debug/in-memory-node#pre-configured-rich-wallets + - Note: every restart will necessitate a reset of MetaMask's cached account data + +Portal started v1.24.2: + - Wallet: http://localhost:3000 + +Block Explorer started v2.48.0: + - App: http://localhost:3010 + - HTTP API: + - Endpoint: http://localhost:3020 + - Documentation: http://localhost:3020/docs +``` + +## Managing running modules + +ZKsync CLI `dev` modules use Docker to create Docker containers to run nodes and ZKsync apps locally. +You can manage these Docker containers using the ZKsync CLI or Docker Desktop GUI. +The Docker Desktop provides an easy way to manage containers, view available ports and read logs. + +You can start, stop and restart modules using ZKsync CLI using the `start`, `stop`, and `restart` sub-commands, respectively. + +The `restart` sub-command can take a module name as an option to restart a specific module. Otherwise it will restart all running modules. + +::callout{icon="i-heroicons-information-circle" color="blue"} +State will not persist between stopping and starting modules. +:: + +### Viewing module logs + +Actively running modules have logs that can be viewed either in Docker Desktop or via ZKsync CLI. +The Docker Desktop provides a more comprehensive and active view of the logs. + +Run the `zksync-cli dev logs` to return a truncated list of logs for all actively running modules. + +## Cleaning modules + +ZKsync CLI `dev` modules can be started and stopped with minimal issues and allow persistence of data between sessions. +If you need to re-start with a fresh install of the modules, +the `zksync-cli dev clean [module name]` sub-command will uninstall all of the module data from your local machine. + +This sub-command deletes all data and requires reinstalling the module upon a new `start`. + +::callout{icon="i-heroicons-exclamation-triangle" color="amber"} +Wallets' cached account data, like nonces, will need to be reset when you restart the ZKsync node module. +Refer to Metamask's [How to clear your account activity/reset account](https://support.metamask.io/managing-my-wallet/resetting-deleting-and-restoring/how-to-clear-your-account-activity-reset-account/). +:: diff --git a/content/00.build/20.zksync-cli/40.zksync-cli-transaction.md b/content/00.build/20.zksync-cli/40.zksync-cli-transaction.md deleted file mode 100644 index c52bff58..00000000 --- a/content/00.build/20.zksync-cli/40.zksync-cli-transaction.md +++ /dev/null @@ -1,87 +0,0 @@ ---- -title: zksync-cli transaction -description: Interact with transaction information using zksync-cli. ---- - -The `zksync-cli transaction info` command is designed to fetch and display detailed information about a specific transaction. -It can be used to check the status, amounts transferred, fees, method signatures, and arguments of transactions. - -## Options - -If no options are provided directly, the CLI will prompt the user to enter the necessary information, such as the chain and transaction hash. - -- `--tx <transaction hash>`: Specify the transaction hash to query. -- `--chain <chain-name>`: Select the chain to use (e.g., `zksync-mainnet`, `zksync-sepolia`). -- `--rpc <url>`: Provide RPC URL instead of selecting a chain -- `--full`: Show all available transaction data for comprehensive insights. -- `--raw`: Display the raw JSON response from the node. -- `--abi <path>`: Path to a local ABI file to decode the transaction's input data. - -## Examples - -### Basic usage - -```bash -zksync-cli transaction info -``` - -You will be prompted to select a chain and transaction hash. - -```bash -? Chain to use: %%zk_testnet_name%% -? Transaction hash: 0x2547ce8219eb7ed5d73e68673b0e4ded83afc732a6c651d43d9dc49bb2f13d40 -``` - -The command will display detailed information about the transaction: - -```bash -──────────────────── Main info ──────────────────── -Transaction hash: 0x2547ce8219eb7ed5d73e68673b0e4ded83afc732a6c651d43d9dc49bb2f13d40 -Status: completed -From: 0x56DDd604011c5F8629bd7C2472E3504Bd32c269b -To: 0xBB5c309A3a9347c0135B93CbD53D394Aa84345E5 -Value: 0 ETH -Fee: 0.0001503581 ETH | Initial: 0.0004 ETH Refunded: 0.0038496419 ETH -Method: transmit(bytes,bytes32[],bytes32[],bytes32) 0xc9807539 - -───────────────── Method arguments ───────────────── -[1] bytes: 0x0000000000000000000000fd69e45d6f51e482ac4f8f2e14f2155200008b5f010001020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000007df298c81a0000000000000000000000000000000000000000000000000000007df298c81a0000000000000000000000000000000000000000000000000000007df298c81a -[2] bytes32[]: 0xd737d65b6b610c3f330bcfddbfc08e46d2a628c88bf22ec0d8f25627a3330798,0x9d33be2ba33b731555c13a4e7bf02d3d576fa3115f7523cbf07732321c85cdba -[3] bytes32[]: 0x73d639deda36b781ae049c8eceafba4196ee8ecc1efb74c538a28ea762ff6658,0x37ac79ff2ca902140613b0e51357d8fb218a67b4736bdee0c268c5fd9812e146 -[4] bytes32: 0x0101000000000000000000000000000000000000000000000000000000000000 - -───────────────────── Details ───────────────────── -Date: 2/8/2024, 2:19:54 PM (15 minutes ago) -Block: #364999 -Nonce: 50131 -``` - -### Parsing transaction data - -By default `zksync-cli` tries to fetch contract verification data from the server. -In case this is not possible it queries the -[open signature](https://www.4byte.directory/) database to get the signature of the transaction method. -If the method signature is not found, the transaction's data is displayed as a hex string. - -Alternatively, you can provide the path to a local ABI file to decode the transaction's input data: - -```bash -zksync-cli transaction info \ - --abi "./Greeter.json" -``` - -### Viewing detailed information - -For an even more detailed overview you can use the `--full` option: - -```bash -zksync-cli transaction info --full -``` - -### Displaying raw JSON response - -To view the raw JSON response from the ZKsync node, use the `--raw` option: - -```bash -zksync-cli transaction info --raw -``` diff --git a/content/00.build/20.zksync-cli/50.configuring-chains.md b/content/00.build/20.zksync-cli/50.configuring-chains.md new file mode 100644 index 00000000..9b2444fa --- /dev/null +++ b/content/00.build/20.zksync-cli/50.configuring-chains.md @@ -0,0 +1,87 @@ +--- +title: Configuring chains +description: Add and manage custom chains with ZKsync CLI +--- + +You can define named chains to use with ZKsync CLI to interact with when running commands. + +Every ZKsync CLI command requires a chain to execute transactions on, and by default, the ZKsync Mainnet, +ZKsync Sepolia Testnet, in-memory local node, and Dockerized local node are provided. +You can add and edit additional chains using the `zksync-cli config chains` sub-command. + +## Using a custom chain + +The ZKsync CLI prompts with a list of default chains as well as your custom chains whenever you run a command without the `--chain` option. +To pass in a chain to a ZKsync CLI command with the `--chain` option, use the **chain key** to refer to the chain of choice. + +```sh +zksync-cli wallet balance --chain example-chain +``` + +## Creating a new chain + +The CLI prompts you to select an existing chain to edit or the option to add a new chain. +Use the arrow keys to navigate to "+ Add new chain" and press Enter to select. + +<!-- spell-checker: disable --> + +```sh +? Select a chain (Use arrow keys) +❯ My ZKchain - my-zkchain + Custom Chain - custom-chain + ────────────── + + Add new chain +``` + +<!-- spell-checker: enable --> + +The CLI then prompts you with several questions for the new chain. +The **Chain name** is a visual label to identify the chain you are adding, +and the **Chain key** is the id to use for referencing the chain when using the `--chain` option. + +If the chain connects to L1, the CLI will also require the L1 details to setup your new chain configuration. + +::callout{icon="i-heroicons-information-circle" color="blue"} +The following is an example of adding a chain for ZKsync Sepolia connected to Ethereum Sepolia. +This configuration is already available in ZKsync CLI by default; you do not need to add this configuration. +:: + +```sh +? Select a chain Add new chain +? Chain id 300 +? Chain name Example Chain +? Chain key example-chain +? Chain RPC URL https://sepolia.era.zksync.dev +? Chain explorer URL (optional) https://sepolia.explorer.zksync.io/ +? Is this chain connected to L1 + No - skip adding L1 chain info +❯ Yes - add L1 chain info +? Is this chain connected to L1 Yes +? L1 Chain id 11155111 +? L1 Chain name Sepolia +? L1 Chain key sepolia +? L1 Chain RPC URL https://rpc.ankr.com/eth_sepolia +? L1 Chain explorer URL (optional) https://sepolia.etherscan.io/ +βœ” Chain "Example Chain" saved +``` + +## Edit an existing chain + +You can edit an existing custom chain by selecting an existing chain from the prompt after running `zksync-cli config chains`. +Select a chain and the CLI will prompt if you want to Edit or Delete the chain. Press Enter to select the Edit option. + +```sh +? Select a chain example-chain +? What do you want to do? (Use arrow keys) +❯ Edit + Delete +``` + +The CLI then goes through the prompt similar to creating a new chain, however the initial value will be displayed in parentheses. + +```sh +? Chain id (300) +``` + +To change the initial value, enter a new value and press Enter to move to the next question. +To leave the initial value unchanged, press Enter with an empty value. diff --git a/content/00.build/20.zksync-cli/50.zksync-cli-wallet.md b/content/00.build/20.zksync-cli/50.zksync-cli-wallet.md deleted file mode 100644 index cafef4b9..00000000 --- a/content/00.build/20.zksync-cli/50.zksync-cli-wallet.md +++ /dev/null @@ -1,67 +0,0 @@ ---- -title: zksync-cli wallet -description: Manage your wallet on ZKsync using zksync-cli. ---- - -Utilize the `zksync-cli wallet` command for an easy way to manage your assets on ZKsync, like token transfers and balance check. - -## Commands - -- `transfer [options]` - Transfer tokens on L2 to another account. -- `balance [options]` - Get token balance of an L2 account. - -## Transfer - -To transfer ETH between accounts on ZKsync, use the following command: - -```bash -zksync-cli wallet transfer -``` - -### Options - -If no options are provided directly, the CLI will prompt the user to enter the necessary information - -- `--amount <0.1>`: Specify the amount to transfer. -- `--chain <chain>`: Select the chain to use. -- `--rpc <URL>`: Override the default L2 RPC URL. -- `--pk`, `--private-key <wallet private key>`: Use the private key of the sender for the transaction. -- `--to`, `--recipient <0x address>`: Define the recipient address on L2. -- `--token <token address>`: Specify an ERC-20 token for the transfer instead of ETH. - -### Examples - -#### Transfer ERC-20 Token - -For transferring ERC-20 tokens, include the `--token` option with the token's contract address: - -```bash -zksync-cli wallet transfer --token 0x3e622317f8C93f7328350cF0B56d9eD4C620C5d6 -``` - -## Balance - -View an L2 wallet's ETH balance using the following command: - -```bash -zksync-cli wallet balance -``` - -### Options - -If no options are provided directly, the CLI will prompt the user to enter the necessary information - -- `--address <0x address>`: Address of the wallet to check. -- `--token <token address>`: Specify an ERC-20 token for the transfer instead of ETH. -- `--chain <chain>`: Chain to use. -- `--rpc <URL>`: Override the default L2 RPC URL. - -### Examples - -#### Checking ERC-20 Token Balance - -To check the balance of a specific ERC-20 token, use the `--token` option, for example: - -```bash -zksync-cli wallet balance --token 0x3e622317f8C93f7328350cF0B56d9eD4C620C5d6 -``` diff --git a/content/00.build/20.zksync-cli/01.troubleshooting.md b/content/00.build/20.zksync-cli/60.troubleshooting.md similarity index 50% rename from content/00.build/20.zksync-cli/01.troubleshooting.md rename to content/00.build/20.zksync-cli/60.troubleshooting.md index 2c089240..3a11e27b 100644 --- a/content/00.build/20.zksync-cli/01.troubleshooting.md +++ b/content/00.build/20.zksync-cli/60.troubleshooting.md @@ -3,12 +3,19 @@ title: Troubleshooting description: Get help with issues related to zksync-cli. --- -Encountering issues with ZKsync CLI? Here are some common problems and step-by-step recommendations for resolving them: +Encountering issues with ZKsync CLI? +Here are some common problems and step-by-step recommendations for resolving them: ## `command not found: zksync-cli` -If you try to use the `zksync-cli` command and receive the `command not found` message, double check if you -have the package installed locally or were using the `npx zksync-cli` command. +If you try to use the `zksync-cli` command and receive the `command not found` message, +check to see if you have the package installed on your machine. + +The following command will list the package and version if you have `zksync-cli` installed globally. + +```sh +npm list -g zksync-cli +``` --- @@ -16,33 +23,30 @@ have the package installed locally or were using the `npx zksync-cli` command. If you encounter an `unknown command` error, follow these steps: -a. **Check the ZKsync CLI Version** +a. **Check the ZKsync CLI version** - Run `zksync-cli --version` to check your current version. - Compare it with the latest version available on [npm](https://www.npmjs.com/package/zksync-cli). -- If your version is lower than the one on npm, follow the steps below. +- If your version is lower than the one on npm, follow the steps under [Update ZKsync CLI](/build/zksync-cli#update-zksync-cli) on Getting Started. + If your version is up-to-date, it's possible that the command was moved or renamed. Use `zksync-cli help` for a list of current commands or refer to the documentation. -b. **Verify Local Installation** +b. **Remove local installations** - Use `npm list zksync-cli` to check if `zksync-cli` is installed in the current directory or any parent directories from where you are running your terminal. -- If it is indeed installed, make sure to uninstall it by running `npm uninstall zksync-cli` in its installation location. -Remove all instances of `zksync-cli` until none are found by `npm list zksync-cli`. +- If it is installed, uninstall it by running `npm uninstall zksync-cli` in its installation location. -c. **Verify Global Installation** +Remove all instances of locally installed `zksync-cli` packages until none are found by `npm list zksync-cli`. + +c. **Verify global installation** - Use `npm list -g zksync-cli` to check if `zksync-cli` is installed globally. -- If it is installed globally, uninstall it using `npm uninstall -g zksync-cli`. d. **Clean npm Cache** - Run `npm cache clean --force`. -e. **Use the Latest Version** - -- As a quick fix, or if the above steps don't resolve the issue, use `npx zksync-cli@latest [command]`, for example, `npx zksync-cli@latest dev start`. - --- ## My version is outdated @@ -54,15 +58,7 @@ above to check and update your ZKsync CLI version. --- -## `command not found: npx` Error - -If you receive a `command not found: npx` error, it means Node.js is not installed or not correctly set up on your system: - -- Install Node.js from [the official website](https://nodejs.org/). This will also install `npm` and `npx`. -- After installation, restart your terminal and try running `npx zksync-cli` again. - ---- - ## Other issues -For all other issues, we encourage you to seek help or report them in our [GitHub Discussions](%%zk_git_repo_zksync-developers%%/discussions/new?category=general&title=[zksync-cli]%20<Title>). +For all other issues, we encourage you to seek help or report them in our +[GitHub Discussions](%%zk_git_repo_zksync-developers%%/discussions/new?category=general&title=[zksync-cli]%20<Title>). diff --git a/content/00.build/20.zksync-cli/60.zksync-cli-bridge.md b/content/00.build/20.zksync-cli/60.zksync-cli-bridge.md deleted file mode 100644 index bfd31d4b..00000000 --- a/content/00.build/20.zksync-cli/60.zksync-cli-bridge.md +++ /dev/null @@ -1,91 +0,0 @@ ---- -title: zksync-cli bridge -description: Facilitate bridge operations between L1 and L2 using zksync-cli. ---- - -Facilitate bridge operations between Ethereum (L1) and ZKsync Era (L2), including token deposits, withdrawals, -and finalizing withdrawals with the `zksync-cli bridge` command. - -## Commands - -- `deposit [options]` - Transfer token from L1 to L2. -- `withdraw [options]` - Transfer token from L2 to L1. -- `withdraw-finalize [options]` - Finalize withdrawal of funds. - -## Deposit - -Transfer ETH from L1 to L2 using the deposit command. - -```bash -zksync-cli bridge deposit -``` - -### Options - -If options are not specified, you will be prompted to enter them. - -- `--to, --recipient <0x address>`: Recipient address on L2. -- `--amount <0.1>`: Amount to deposit. -- `--token <0x address>`: ERC-20 token address. -- `--pk, --private-key <wallet private key>`: Private key of the sender. -- `--chain <chain>`: Chain to use. -- `--l1-rpc <URL>`: Override L1 RPC URL. -- `--rpc <URL>`: Override L2 RPC URL. - -### Examples - -#### Depositing ERC-20 Tokens - -To deposit ERC-20 tokens, include the `--token` option with the token's contract address: - -```bash -zksync-cli bridge deposit --token 0x3e622317f8C93f7328350cF0B56d9eD4C620C5d6 -``` - -## Withdraw - -Transfer tokens from L2 back to L1. - -```bash -zksync-cli bridge withdraw -``` - -### Options - -You will be prompted to enter options if they are not specified. - -- `--to, --recipient <0x address>`: Recipient address on L1. -- `--amount <0.1>`: Amount to withdraw. -- `--token <0x address>`: ERC-20 token address (omit this option to withdraw ETH). -- `--pk, --private-key <wallet private key>`: Private key of the sender. -- `--chain <chain>`: Chain to use. -- `--l1-rpc <URL>`: Override L1 RPC URL. -- `--rpc <URL>`: Override L2 RPC URL. - -### Examples - -#### Withdrawing ERC-20 Tokens - -For withdrawing ERC-20 tokens, specify the token address using the `--token` option: - -```bash -zksync-cli bridge withdraw --token 0x3e622317f8C93f7328350cF0B56d9eD4C620C5d6 -``` - -## Withdraw Finalize - -Finalize the withdrawal of funds with the following command. **This step is necessary to complete the withdrawal process initiated on L2.** - -```bash -zksync-cli bridge withdraw-finalize -``` - -### Options - -Options will be prompted if not specified. - -- `--hash <transaction_hash>`: L2 withdrawal transaction hash to finalize. -- `--pk, --private-key <wallet private key>`: Private key of the sender. -- `--chain <chain>`: Chain to use. -- `--l1-rpc <URL>`: Override L1 RPC URL. -- `--rpc <URL>`: Override L2 RPC URL. diff --git a/content/00.build/20.zksync-cli/70.zksync-cli-config-chains.md b/content/00.build/20.zksync-cli/70.zksync-cli-config-chains.md deleted file mode 100644 index 6d50e58f..00000000 --- a/content/00.build/20.zksync-cli/70.zksync-cli-config-chains.md +++ /dev/null @@ -1,33 +0,0 @@ ---- -title: zksync-cli config chains -description: Configure custom chains to use with zksync-cli. ---- - -Specify your own chain configuration by adding or editing custom chains to use on `zksync-cli`. -This feature is essential for developers looking to interact with ZK Stack Chains. - -## Configuring Custom Chains - -To add or edit a custom chain, use the following command: - -```bash -zksync-cli config chains -``` - -Upon execution, you will be guided through a series of prompts to enter specific details for the custom chain, including: - -- **Chain ID**: The id for the chain. -- **Chain Name**: A name for the chain. -- **Chain key**: A unique identifier for the chain. -- **RPC URL**: The RPC endpoint URL for interacting with the chain. -- **Other Information**: Depending on the chain's requirements, you may need to provide additional information such as block explorer URLs. - -## Using Custom Chains - -Once a custom chain is configured, you can use it across various `zksync-cli` commands. -All of your custom chains will be listed in the chain selection prompt, allowing you to select and use them as needed. -You can also specify a custom chain directly using the `--chain` option, for example: - -```bash -zksync-cli wallet balance --chain <custom-chain-key> -``` diff --git a/content/00.build/20.zksync-cli/90.reference/00.index.md b/content/00.build/20.zksync-cli/90.reference/00.index.md new file mode 100644 index 00000000..dbf8c35a --- /dev/null +++ b/content/00.build/20.zksync-cli/90.reference/00.index.md @@ -0,0 +1,12 @@ +--- +title: Overview +description: ZKsync CLI commands reference +--- + +- [`bridge`](/build/zksync-cli/reference/zksync-cli-bridge): Perform deposits and withdrawals between Ethereum and ZKsync. +- [`config chains`](/build/zksync-cli/reference/zksync-cli-config-chains): Add or edit custom chains for flexible testing and development. +- [`contract`](/build/zksync-cli/reference/zksync-cli-contract): Read and write data to ZKsync contracts without building UI. +- [`create`](/build/zksync-cli/reference/zksync-cli-create): Scaffold new projects using templates for frontend, contracts, and scripting. +- [`dev`](/build/zksync-cli/reference/zksync-cli-dev): Start a local development environment with ZKsync and Ethereum nodes. +- [`transaction`](/build/zksync-cli/reference/zksync-cli-transaction): Fetch and display detailed information about a specific transaction. +- [`wallet`](/build/zksync-cli/reference/zksync-cli-wallet): Manage ZKsync wallet assets, including transfers and balance checks. diff --git a/content/00.build/20.zksync-cli/90.reference/05.zksync-cli-bridge.md b/content/00.build/20.zksync-cli/90.reference/05.zksync-cli-bridge.md new file mode 100644 index 00000000..723264e9 --- /dev/null +++ b/content/00.build/20.zksync-cli/90.reference/05.zksync-cli-bridge.md @@ -0,0 +1,104 @@ +--- +title: zksync-cli bridge +description: Facilitate bridge operations between L1 and L2 using zksync-cli. +--- + + +```sh +zksync-cli bridge [sub-command] [options] +``` + +## Description + +This command facilitates bridge operations between Ethereum (L1) and ZKsync Era (L2), including token deposits, withdrawals, +and finalizing withdrawals. + +## `deposit` + +Transfer ETH or ERC20 tokens from L1 to L2. + +```sh +zksync-cli bridge deposit [options] +``` + +::field-group + ::field{name="--amount" type="string" required} + The amount in base decimal format. Example: "0.1" -> 0.1 ETH + :: + ::field{name="--recipient" type="0x address" required} + The address of the receiver. + :: + ::field{name="--token" default="ETH Address" type="0x address"} + The address of the ETH or ERC20 token. + :: + ::field{name="--private-key, --pk" type="string" required} + The private key to generate the transaction. + :: + ::field{name="--chain" type="chain id" required} + The id of the chain to create the transaction on. + :: + ::field{name="--rpc" type="string"} + Override the defined L2 RPC URL for the Chain specified. + :: + ::field{name="--l1-rpc" type="string"} + Override the defined L1 RPC URL for the Chain specified. + :: +:: + +## `withdraw` + +Transfer ETH or ERC20 tokens from L2 to L1. + +```sh +zksync-cli bridge deposit [options] +``` + +::field-group + ::field{name="--amount" type="string" required} + The amount in base decimal format. Example: "0.1" -> 0.1 ETH + :: + ::field{name="--recipient" type="0x address" required} + The address of the receiver. + :: + ::field{name="--token" type="0x address"} + The address of the ETH or ERC20 token. + :: + ::field{name="--private-key, --pk" type="string" required} + The private key to generate the transaction. + :: + ::field{name="--chain" type="chain id" required} + The id of the chain to create the transaction on. + :: + ::field{name="--rpc" type="string"} + Override the defined RPC URL for the Chain specified. + :: + ::field{name="--l1-rpc" type="string"} + Override the defined RPC URL for the Chain's L1. + :: +:: + +## `withdraw-finalize` + +Finalize the withdrawal of funds. **This step is necessary to complete the withdrawal process initiated on L2.** + +```sh +zksync-cli bridge withdraw-finalize [options] +``` + +::field-group + ::field{name="--hash" type="transaction hash" required} + The address of the L2 withdrawal transaction to finalize. + :: + ::field{name="--private-key, --pk" type="string" required} + The private key to generate the transaction. + :: + ::field{name="--chain" type="chain id" required} + The id of the chain to create the transaction on. + :: + ::field{name="--rpc" type="URL"} + Override the defined RPC URL for the Chain specified. + :: + ::field{name="--l1-rpc" type="URL"} + Override the defined RPC URL for the Chain's L1. + :: +:: diff --git a/content/00.build/20.zksync-cli/90.reference/15.zksync-cli-config-chains.md b/content/00.build/20.zksync-cli/90.reference/15.zksync-cli-config-chains.md new file mode 100644 index 00000000..63eb0cef --- /dev/null +++ b/content/00.build/20.zksync-cli/90.reference/15.zksync-cli-config-chains.md @@ -0,0 +1,39 @@ +--- +title: zksync-cli config chains +description: Configure custom chains to use with zksync-cli. +--- + +```sh +zksync-cli config chains +``` + +## Description + +Specify your own chain configuration by adding or editing custom chains to use. Run the `zksync-cli config chains` command to display a list +of configured chains along with an option to **Add a new chain**. + +When adding a new chain, the CLI prompts you with questions for the new chain data. + +::field-group + ::field{name="id" type="number" required} + The unique ID of the network. Example: %%zk_mainnet_chain_id%% for %%zk_mainnet_name%%. + :: + ::field{name="name" type="string" required} + The name of the chain for reference. + :: + ::field{name="network" type="string" required} + The ID to reference the chain when using the `--chain` option with other zksync-cli commands. + :: + ::field{name="rpc url" type="string" required} + The RPC URL for the network. + :: + ::field{name="explorer url" type="URL"} + The URL to the Block Explorer for the network. + :: + ::field{name="verification api url" type="URL"} + The URL to the verification API for verifying smart contracts. + :: + ::field{name="l1 chain" type="chain"} + The chain data for the L1 the L2 chain is connected to. + :: +:: diff --git a/content/00.build/20.zksync-cli/90.reference/19.zksync-cli-contract.md b/content/00.build/20.zksync-cli/90.reference/19.zksync-cli-contract.md new file mode 100644 index 00000000..9a1c1f29 --- /dev/null +++ b/content/00.build/20.zksync-cli/90.reference/19.zksync-cli-contract.md @@ -0,0 +1,117 @@ +--- +title: zksync-cli contract +description: ZKsync CLI contract command reference +--- + +```sh +zksync-cli contract [sub-command] [options] +``` + +## Description + +The `contract` command provides several sub-commands to interact with transactions via the command line. + +## `read` + +```sh +zksync-cli contract read [options] +``` + +::field-group + ::field{name="--chain" type="chain id" required} + The id of the chain to create the transaction. + :: + ::field{name="--rpc" type="URL"} + Override the defined L2 RPC URL for the Chain specified. + :: + ::field{name="--contract" type="0x address"} + The address of the smart contract. + :: + ::field{name="--method" type="string"} + The method with argument types in the smart contract to interact with. + + Example: `"balanceOf(address)"` + :: + ::field{name="--args, --arguments" type="string[]"} + The arguments for the smart contract method. + :: + ::field{name="--data" type="string"} + The encoded transaction data to add to the transaction. + :: + ::field{name="--output, --outputTypes" type="string[]"} + The expected output types returned from the method. + :: + ::field{name="--from" type="0x address"} + The address to read on behalf of. + :: + ::field{name="--abi" type="string"} + The relative file location of the contract artifact or ABI file. + :: + ::field{name="--decode-skip" type="boolean"} + Set to true to skip the decoding response. + :: + ::field{name="--show-info" type="boolean"} + Set to true to show the transaction request information (e.g. encoded data). + :: +:: + +## `write` + +```sh +zksync-cli contract write [options] +``` + +::field-group + ::field{name="--chain" type="chain id" required} + The id of the chain to create the transaction. + :: + ::field{name="--rpc" type="URL"} + Override the defined L2 RPC URL for the Chain specified. + :: + ::field{name="--contract" type="0x address"} + The address of the smart contract. + :: + ::field{name="--method" type="string"} + The method with argument types in the smart contract to interact with. + + Example: `"transfer(address, uint256)"` + :: + ::field{name="--args, --arguments" type="string[]"} + The arguments for the smart contract method. + :: + ::field{name="--value" type="Ether amount"} + The Ether value to send with the transaction. + :: + ::field{name="--data" type="string"} + The encoded transaction data to add to the transaction. + :: + ::field{name="--private-key, --pk" type="string"} + The private key of the sender used to generate the transaction. + :: + ::field{name="--abi" type="string"} + The relative file location of the contract artifact or ABI file. + :: + ::field{name="--show-info" type="boolean"} + Set to true to show the transaction request information (e.g. encoded data). + :: +:: + +## `encode` + +```sh +zksync-cli contract encode [options] +``` + +::field-group + ::field{name="--method" type="string"} + The method with argument types in the smart contract to interact with. + + Example: `"transfer(address, uint256)"` + :: + ::field{name="--args, --arguments" type="string[]"} + The arguments for the smart contract method. + :: + ::field{name="--abi" type="string"} + The relative file location of the contract artifact or ABI file. + :: +:: diff --git a/content/00.build/20.zksync-cli/20.zksync-cli-create.md b/content/00.build/20.zksync-cli/90.reference/20.zksync-cli-create.md similarity index 71% rename from content/00.build/20.zksync-cli/20.zksync-cli-create.md rename to content/00.build/20.zksync-cli/90.reference/20.zksync-cli-create.md index a133cef9..5e25e43c 100644 --- a/content/00.build/20.zksync-cli/20.zksync-cli-create.md +++ b/content/00.build/20.zksync-cli/90.reference/20.zksync-cli-create.md @@ -1,17 +1,23 @@ --- title: zksync-cli create -description: Use the zksync-cli create command to streamline project setup. +description: ZKsync CLI create command reference --- The `zksync-cli create` command streamlines project setup by offering templates for frontend development, smart contracts, -and scripting for ZKsync, enabling rapid deployment and development. +and scripting for ZKsync. -### Prerequisites - -Ensure you have the following installed before you start: +```sh +zksync-cli create [folder name] [options] +``` -- [Node.js](https://nodejs.org) v18+ -- [Git](https://git-scm.com/downloads) +::field-group + ::field{name="--project"} + The project type to select templates from, either `contracts`, `frontend`, or `scripting`. + :: + ::field{name="--template"} + The project template to use. Choices are listed with the `zksync-cli create --help` command. + :: +:: ## Available Templates @@ -37,12 +43,3 @@ Enhance your project with Node.js scripting templates for automated interactions Includes examples of wallet or contract interactions using viem, ethers, or web3.js. ZKsync Scripting Examples repo can be found [here](%%zk_git_repo_zksync-scripting-templates%%#readme) - -## Using Templates - -To create a project using a template, run the following command and follow the prompts to select your desired template category -and specific framework or tool: - -```bash -zksync-cli create -``` diff --git a/content/00.build/20.zksync-cli/90.reference/25.zksync-cli-dev.md b/content/00.build/20.zksync-cli/90.reference/25.zksync-cli-dev.md new file mode 100644 index 00000000..908aa93b --- /dev/null +++ b/content/00.build/20.zksync-cli/90.reference/25.zksync-cli-dev.md @@ -0,0 +1,113 @@ +--- +title: zksync-cli dev +description: ZKsync CLI dev command reference +--- + +## Prerequisites + +You will need [Docker](https://www.docker.com) to setup ZKsync nodes on your local machine. +[Download and install Docker](https://www.docker.com/get-started/) which will install the necessary tools for the `dev` command to work. + +Once installed, ensure that the Docker program is running on your machine, otherwise the `dev` command may error. +Check to make sure that the Docker Desktop is running anytime you restart your machine. + +```sh +zksync-cli dev [sub-command] [options] +``` + +## `config` + +```sh +zksync-cli dev config [options] +``` + +An interactive command to select the default modules to run in local development environment. + +## `start` + +```sh +zksync-cli dev start [options] +``` + +Start local ZKsync CLI dev modules. + +## `stop` + +```sh +zksync-cli dev stop [options] +``` + +Stop currently running local ZKsync CLI dev modules. + +## `restart` + +```sh +zksync-cli dev restart [module] [options] +``` + +Restart running local ZKsync CLI dev modules. +Pass a module name to restart only that module. + +## `logs` + +```sh +zksync-cli dev logs [module] [options] +``` + +Displays truncated list of logs for configured ZKsync CLI dev modules. + +## `clean` + +```sh +zksync-cli dev clean [module] [options] +``` + +Removes data for all configured ZKsync CLI dev modules. + +## `install` + +```sh +zksync-cli dev install [module] [options] +zksync-cli dev i [module] [options] +``` + +Install a ZKsync CLI dev module with NPM. + +::field{name="--link" type="boolean"} +Use 'npm link' instead of 'npm install' (useful during module development). +:: + +## `update` + +```sh +zksync-cli dev update [module] [options] +``` + +Update a ZKsync CLI dev module version. + +::field-group + ::field{name="--force" type="boolean"} + Force upddate the module (skip version check). + :: + ::field{name="--package" type="boolean"} + Update the NPM package instead of module. + :: +:: + +## `uninstall` + +```sh +zksync-cli dev uninstall [module] [options] +``` + +::field{name="--unlink" type="boolean"} +Use 'npm unlink' instead of 'npm uninstall' (useful during module development). +:: + +## `modules` + +```sh +zksync-cli dev modules [module] [options] +``` + +Lists currently installed ZKsync CLI dev modules. diff --git a/content/00.build/20.zksync-cli/90.reference/40.zksync-cli-transaction.md b/content/00.build/20.zksync-cli/90.reference/40.zksync-cli-transaction.md new file mode 100644 index 00000000..7045bc61 --- /dev/null +++ b/content/00.build/20.zksync-cli/90.reference/40.zksync-cli-transaction.md @@ -0,0 +1,39 @@ +--- +title: zksync-cli transaction +description: Interact with transaction information using zksync-cli. +--- + +```sh +zksync-cli transaction [sub-command] [options] +``` + +## Description + +This command allows you to fetch and display detailed information of transactions via the CLI. + +## `info` + +```sh +zksync-cli transaction info [options] +``` + +::field-group + ::field{name="--chain" type="chain id" required} + The ID of the chain to create the transaction on. + :: + ::field{name="--transaction, --tx" type="transaction hash"} + The transaction hash to read from. + :: + ::field{name="--full" type="boolean"} + Set to true to show all available data for the transaction. + :: + ::field{name="--raw" type="boolean"} + Set to true to show the raw JSON response of the transaction. + :: + ::field{name="--abi" type="string"} + The relative path to a contract artifact or ABI file. + :: + ::field{name="--rpc" type="string"} + Override the defined L2 RPC URL for the selected chain. + :: +:: diff --git a/content/00.build/20.zksync-cli/90.reference/50.zksync-cli-wallet.md b/content/00.build/20.zksync-cli/90.reference/50.zksync-cli-wallet.md new file mode 100644 index 00000000..12db855c --- /dev/null +++ b/content/00.build/20.zksync-cli/90.reference/50.zksync-cli-wallet.md @@ -0,0 +1,59 @@ +--- +title: zksync-cli wallet +description: Manage your wallet on ZKsync using zksync-cli. +--- + +```sh +zksync-cli wallet [sub-command] [options] +``` + +## Description + +This command allows you to interact with a wallet. +You can review your balance of ETH or ERC20 token as well as +transfer ETH and ERC20 tokens between L2 addresses. + +## `balance` + +```sh +zksync-cli wallet balance [options] +``` + +::field-group + ::field{name="--chain" type="chain id" required} + The ID of the chain to create the transaction on. + :: + ::field{name="--address" type="0x address" required} + The address to check the balance of. + :: + ::field{name="--token" default="ETH Address" type="0x address"} + The address of the ETH or ERC20 token. + :: + ::field{name="--rpc" type="string"} + Override the defined L2 RPC URL for the selected chain. + :: +:: + +## `transfer` + +```sh +zksync-cli wallet transfer [options] +``` + +::field-group + ::field{name="--amount" type="string" required} + The amount in base decimal unit format. Example: "0.1" -> 0.1 ETH + :: + ::field{name="--chain" type="chain id" required} + The ID of the chain to create the transaction on. + :: + ::field{name="--address" type="0x address" required} + The address to check the balance of. + :: + ::field{name="--token" default="ETH Address" type="0x address"} + The address of the ETH or ERC20 token. + :: + ::field{name="--rpc" type="string"} + Override the defined L2 RPC URL for the selected chain. + :: +:: diff --git a/content/00.build/20.zksync-cli/90.reference/_dir.yml b/content/00.build/20.zksync-cli/90.reference/_dir.yml new file mode 100644 index 00000000..ed0586f7 --- /dev/null +++ b/content/00.build/20.zksync-cli/90.reference/_dir.yml @@ -0,0 +1 @@ +title: CLI Reference diff --git a/content/00.build/40.tooling/20.hardhat/60.hardhat-zksync-deploy.md b/content/00.build/40.tooling/20.hardhat/60.hardhat-zksync-deploy.md index a742ff85..9dc170a6 100644 --- a/content/00.build/40.tooling/20.hardhat/60.hardhat-zksync-deploy.md +++ b/content/00.build/40.tooling/20.hardhat/60.hardhat-zksync-deploy.md @@ -13,7 +13,7 @@ To use the `hardhat-zksync-deploy` in your project, we recommend that: - You have a Node installation and `yarn` or `npm` package manager. - You are already familiar with deploying smart contracts on ZKsync Era. -If not, please refer to the first section of the [ZKsync 101 material](/build/zksync-101/hello-zksync). +If not, please refer to the first section of the [ZKsync 101 material](/build/start-coding/zksync-101/hello-zksync). - A wallet with sufficient Sepolia `ETH` on Ethereum and %%zk_testnet_name%% to pay for deploying smart contracts on testnet. diff --git a/content/00.build/90.contributing-to-documentation/30.documentation-styleguide.md b/content/00.build/90.contributing-to-documentation/30.documentation-styleguide.md index e2710141..53de9ebf 100644 --- a/content/00.build/90.contributing-to-documentation/30.documentation-styleguide.md +++ b/content/00.build/90.contributing-to-documentation/30.documentation-styleguide.md @@ -114,7 +114,7 @@ For example, the file `/content/1.quick-start/2.deploy-contract.md` is defined a Example link to an internal page using markdown format, with an anchor tag. ```md -[Getting Started](/build/zksync-101#install-docker) +[Getting Started](/build/start-coding/zksync-101#install-docker) ``` ## Markdown and Vue components @@ -179,14 +179,14 @@ A callout should not contain anything essential to understanding the main conten #### Example ::callout{icon="i-heroicons-exclamation-triangle" color="amber"} -This is a `callout` with full **markdown** support. It can have markdown content like a link to [another page](/build/zksync-101). +This is a `callout` with full **markdown** support. It can have markdown content like a link to [another page](/build/start-coding/zksync-101). :: #### Code ```md ::callout{icon="i-heroicons-exclamation-triangle" color="amber"} -This is a `callout` with full **markdown** support. It can have markdown content like a link to [another page](/build/zksync-101). +This is a `callout` with full **markdown** support. It can have markdown content like a link to [another page](/build/start-coding/zksync-101). :: ``` diff --git a/content/index.yml b/content/index.yml index 11e129c0..56aeeea5 100644 --- a/content/index.yml +++ b/content/index.yml @@ -19,7 +19,7 @@ features: - title: 'Getting Started with ZKsync' description: 'Jumpstart your ZKsync journey with quickstart guides and fundamental concepts for developers.' icon: 'i-zksync-zksync-logo' - to: '/build/quick-start' + to: '/build/start-coding/quick-start' - title: 'Develop with zksync-cli' description: 'Boost your development workflow with the zksync-cli tool.' icon: 'i-simple-icons-windowsterminal' diff --git a/firebase.json b/firebase.json index 98f481ea..6dfa9b70 100644 --- a/firebase.json +++ b/firebase.json @@ -101,8 +101,13 @@ "type": 301 }, { - "source": "/build/quick-start/*.@(html|md)", - "destination": "/build/quick-start", + "source": "/build/quick-start/*", + "destination": "/build/start-coding/quick-start", + "type": 301 + }, + { + "source": "/build/zksync-101/*", + "destination": "/build/start-coding/zksync-101", "type": 301 }, { @@ -115,9 +120,14 @@ "destination": "/build/zksync-cli", "type": 301 }, + { + "source": "/build/tooling/zksync-cli/troubleshooting", + "destination": "/build/zksync-cli/troubleshooting", + "type": 301 + }, { "source": "/build/tooling/zksync-cli/*", - "destination": "/build/zksync-cli", + "destination": "/build/zksync-cli/reference", "type": 301 }, {