Skip to content

Commit

Permalink
docs: update the zksync-cli section (#165)
Browse files Browse the repository at this point in the history
# 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
  • Loading branch information
itsacoyote authored Jul 31, 2024
1 parent d2d3e8e commit 7ec9441
Show file tree
Hide file tree
Showing 67 changed files with 1,355 additions and 673 deletions.
4 changes: 2 additions & 2 deletions content/00.build/00.index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ 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.
::
::card
---
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.
::
Expand Down
2 changes: 1 addition & 1 deletion content/00.build/01.connect-to-zksync.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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).
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"}

---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"}

---

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Original file line number Diff line number Diff line change
Expand Up @@ -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"}

---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"}

---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"}

---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"}

---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"}

---

Expand Down
1 change: 1 addition & 0 deletions content/00.build/05.start-coding/_dir.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
title: Start Coding 🚀
46 changes: 26 additions & 20 deletions content/00.build/20.zksync-cli/00.index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
80 changes: 80 additions & 0 deletions content/00.build/20.zksync-cli/05.reading-transaction-data.md
Original file line number Diff line number Diff line change
@@ -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
```
Loading

0 comments on commit 7ec9441

Please sign in to comment.