Skip to content

Commit

Permalink
docs(zkstack_cli): apply redesign ZK Toolbox commands (#96)
Browse files Browse the repository at this point in the history
<!--

Thank you for contributing to the ZKsync Code Community!

Before submitting the PR, please make sure you do the following:

- Read the [Contributing
Guide](https://github.com/ZKsync-Community-Hub/community-code/blob/main/CONTRIBUTING.md).
- Understand our [Code of
Conduct](https://github.com/ZKsync-Community-Hub/community-code/blob/main/CODE_OF_CONDUCT.md)
-->
# Description
Apply redesign ZK Toolbox commands to tutorials.

<!-- Please describe what are the changes and what they are solving for
in this PR. -->

## Linked Issues

<!-- If you have any issues this PR is related to, link them here. -->
<!--
Check out
https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue
on how to automate linking a GitHub Issue to a PR.
-->

## Additional context

---------

Co-authored-by: Antonio <[email protected]>
  • Loading branch information
manuelmauro and uF4No authored Oct 14, 2024
1 parent a122f99 commit 4016397
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 39 deletions.
54 changes: 27 additions & 27 deletions content/tutorials/custom-zk-chain/10.index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Getting Started with ZK Chains
description: Create and run your first ZK chain.
---

This tutorial shows you how to use the `zk_inception` CLI to run an Elastic Chain ecosystem and custom ZK chain locally:
This tutorial shows you how to use the ZK Stack CLI to run an Elastic Chain ecosystem and custom ZK chain locally:

- You'll set up a local **Elastic Chain ecosystem**
- You'll create a standard **ZK chain**
Expand All @@ -18,24 +18,24 @@ This tutorial shows you how to use the `zk_inception` CLI to run an Elastic Chai
- For background on the Elastic Chain or ZK chains, read the [ZK chains](https://docs.zksync.io/zk-stack/concepts/zk-chains) section in our docs.
- Install the dependencies for the `zksync-era` repo by following the instructions in the matter-labs/zksync-era project's [Setup dev guide](https://github.com/matter-labs/zksync-era/blob/main/docs/guides/setup-dev.md)
(you can skip the "Environment" section).
- Install the latest version of [foundry-zksync](https://foundry-book.zksync.io/getting-started/installation).

::callout{icon="i-heroicons-light-bulb"}
If you previously have `foundry-zksync` installed,
reinstall the normal version of [foundry](https://book.getfoundry.sh/getting-started/installation) for this tutorial.
::
## Installing ZK Stack CLI

You can use `zkstackup` to install and manage `zkstack`:

## Installing `zk_inception` CLI
```bash
curl -L https://raw.githubusercontent.com/matter-labs/zksync-era/main/zkstack_cli/zkstackup/install | bash
```

To install the CLI globally, run this command in your root folder.
You can use the Rust command `cargo` to install the CLI with the command below:
Then install the most recent version of `zkstack` with:

```bash
cargo install --git https://github.com/matter-labs/zksync-era/ \
--locked zk_inception --force
zkstackup
```

::callout{icon="i-heroicons-light-bulb"}
You can find a full reference for the `zk_inception` CLI in the [`zksync-era` repo](https://github.com/matter-labs/zksync-era/tree/main/zk_toolbox/crates/zk_inception).
You can find a full reference for the ZK Stack CLI in the [`zksync-era` repo](https://github.com/matter-labs/zksync-era/tree/main/zkstack_cli).
::

## Setting up the Elastic Chain ecosystem
Expand All @@ -49,9 +49,9 @@ There are two components needed for running a ZK chain locally:
1. An Elastic Chain ecosystem to manage different chains
2. At least one chain deployed within the ecosystem

To setup both of these components, use the `zk_inception` CLI.
To setup both of these components, use ZK Stack CLI.

The first step is to create a new ecosystem with the `ecosystem create` command.
The first step is to create a new ecosystem with the `zkstack ecosystem create` command.

::callout{icon="i-heroicons-light-bulb"}
Make sure Docker is running on your machine.
Expand All @@ -60,17 +60,17 @@ Make sure Docker is running on your machine.
Move to a directory where you want your ecosystem folder to be, and run the command below to generate an ecosystem folder.

```bash
zk_inception ecosystem create
zkstack ecosystem create
```

You will be prompted with a series of options to customize your ecosystem and generate a new chain within the ecosystem.
For this tutorial, use the options shown below.
If you choose different names for your ecosystem or chain, remember to update the names in the commands later on.

```bash
$ zk_inception ecosystem create
❯ zkstack ecosystem create

ZKsync toolbox
ZK Stack CLI
◇ What do you want to name the ecosystem?
│ my_elastic_chain
Expand All @@ -84,7 +84,7 @@ $ zk_inception ecosystem create
◇ What do you want to name the chain?
│ zk_chain_1
Whats the chain id?
What's the chain id?
│ 271
◇ Select how do you want to create the wallet
Expand Down Expand Up @@ -148,10 +148,10 @@ Move into the ecosystem folder:
cd my_elastic_chain
```

Next, run the `ecosystem init` command below to deploy the ecosystem:
Next, run the `zkstack ecosystem init` command below to deploy the ecosystem:

```bash
zk_inception ecosystem init --dev
zkstack ecosystem init --dev
```

The `--dev` flag will choose the default options for development.
Expand All @@ -163,7 +163,7 @@ If you have any issues at this step, try reinstalling the dependencies at the to
This process will take some time as there is a lot happening here.
To see more detailed logs of what is happening at each step, you can add the `--verbose` flag to the command.

To summarize, the `ecosystem init` command:
To summarize, the `zkstack ecosystem init` command:

- Checks to see if your environment has the necessary dependencies.
- Compiles and deploys all of the necessary contracts for the ecosystem.
Expand All @@ -178,19 +178,19 @@ For the ERC20 contracts, you can find the deployed addresses inside `<my_elastic

### Understanding the chain configs

Running the `init` command will also modify your chain configuration files in the ecosystem folder.
Running the `zkstack ecosystem init` subcommand will also modify your chain configuration files in the ecosystem folder.

The main configuration file for `zk_chain_1` can be found in `<my_elastic_chain>/chains/zk_chain_1/ZkStack.yaml`.
It contains the most basic configurations for the chain.

Inside `<my_elastic_chain>/chains/zk_chain_1/configs`, you can find six more configuration files:

1. `contracts.yaml`: configurations for all the L1 & L2 contracts.
1. `external_node.yaml`: configurations for the chain's node server.
1. `general.yaml`: general configurations.
1. `genesis.yaml`: chain specific configurations with parameters that were used during genesis.
1. `secrets.yaml`: secrets that are individual for every chain.
1. `wallets.yaml`: all wallets that you are using for this chain.
2. `external_node.yaml`: configurations for the chain's node server.
3. `general.yaml`: general configurations.
4. `genesis.yaml`: chain specific configurations with parameters that were used during genesis.
5. `secrets.yaml`: secrets that are individual for every chain.
6. `wallets.yaml`: all wallets that you are using for this chain.
::callout{icon="i-heroicons-exclamation-triangle" color="amber"}
Never commit your private keys or sensitive secrets.
Expand All @@ -201,7 +201,7 @@ Never commit your private keys or sensitive secrets.
The last step here is to start a server for `zk_chain_1`:
```bash
zk_inception server
zkstack server
```
With this, your L1 chain should be running at port `8545`, and the `zk_chain_1` node should be running at port `3050`.
Expand Down
22 changes: 11 additions & 11 deletions content/tutorials/custom-zk-chain/20.customizing-your-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,18 +175,18 @@ Now that your ERC20 token is deployed, you can create a new chain.

First, shut down the node server running for `zk_chain_1` by terminating the process.

Move back into your elastic chain ecosystem folder and run the `chain create` command:
Move back into your elastic chain ecosystem folder and run the `zkstack chain create` subcommand:

```bash
zk_inception chain create
zkstack chain create
```

This time, use the answers below:

```bash
$ zk_inception chain create
❯ zkstack chain create

ZKsync toolbox
ZK Stack CLI
◇ What do you want to name the chain?
│ custom_zk_chain
Expand Down Expand Up @@ -233,15 +233,15 @@ Make sure the server for `zk_chain_1` that you started in the previous section i
Next, initialize the chain in the ecosystem with the command below, and select the default options for the prompts.

```bash
zk_inception chain init
zkstack chain init
```

During the initialization process, your ERC20 token address gets added to the allowlist mentioned earlier.

Now that the chain is initialized, you can start the chain server:

```bash
zk_inception server
zkstack server
```

## Bridging the base token to your chain
Expand Down Expand Up @@ -345,10 +345,10 @@ L2 ETH Balance 🎉: 20000000000000000000n
You can switch in between different chains without losing any state by terminating the chain server process and then running the command below:
```bash
zk_inception ecosystem change-default-chain
zkstack ecosystem change-default-chain
```
Now when you start the server with `zk_inception server`, the new default chain's node will start with the saved state.
Now when you start the server with `zkstack server`, the new default chain's node will start with the saved state.
To fully shut down the ecosystem and erase all of the data and state,
you can shut down the Docker containers from the ecosystem folder using the command:
Expand All @@ -359,11 +359,11 @@ docker-compose down
To restart the docker containers for your ecosystem and run your custom ZK chain again, follow the steps below:
1. In the ecosystem folder, run `zk_inception containers`.
1. In the ecosystem folder, run `zkstack containers`.
1. Redeploy your ERC20 contract to the L1.
1. Update the base token address in `<my_elastic_chain>/chains/custom_zk_chain/configs/contracts.yaml` under `l1.base_token_addr` and in
`<my_elastic_chain>/chains/custom_zk_chain/ZkStack.yaml` under `base_token.address`.
1. Send ERC20 tokens to both of the ecosystem and chain governor addresses.
1. Initialize the ecosystem with `zk_inception ecosystem init --dev`.
1. Start the chain server with `zk_inception server`.
1. Initialize the ecosystem with `zkstack ecosystem init --dev`.
1. Start the chain server with `zkstack server`.
1. Bridge ERC20 tokens from the L1 to L2.
2 changes: 1 addition & 1 deletion content/tutorials/custom-zk-chain/_dir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ what_you_will_learn:
- How to setup a ZK chain with a custom base token.
updated: 2024-08-14
tools:
- zk_inception
- zkstack
- hardhat
- cast
- zksync-cli
Expand Down
1 change: 1 addition & 0 deletions cspell-config/cspell-zksync.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ zknode
zkout
zksolc
zkstack
zkstackup
!zkSync
zksync
ZKsync
Expand Down

0 comments on commit 4016397

Please sign in to comment.