Skip to content

Commit

Permalink
docs: add review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahschwartz committed Aug 1, 2024
1 parent 8a06db0 commit 326b486
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
12 changes: 8 additions & 4 deletions content/tutorials/custom-zk-chain/10.index.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,23 @@ There are two components needed for running a ZK chain locally:
2. A chain deployed within the ecosystem

To setup both of these components, use the `zk_inception` CLI.
To install the CLI globally, run this command in your root folder.
You can use `cargo` to install the CLI with the command below:

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

Once you have that installed, the first step is to create a new ecosystem with the `ecosystem create` command:
Once you have that installed, the first step is to create a new ecosystem with the `ecosystem create` command.
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
```

::callout{icon="i-heroicons-light-bulb"}
Make sure to have Docker open.
Make sure to have the Docker daemon running.
::

You will be prompted with a series of options to customize your ecosystem and generate a new chain within the ecosystem.
Expand Down Expand Up @@ -92,7 +94,7 @@ By running this command and selecting these options, you just:
- Created a new ecosystem called `my_elastic_chain`, which can contain many chains.
- Cloned the `zksync-era` repository inside the `my_elastic_chain` folder.
- Chose to use a local network to act as the L1.
This means we'll have to run a local reth node as well (don't worry, we've setup everything you need for this too!).
This means we'll have to run a local reth node as well (don't worry, the CLI will automatically set this up and run it for you!).
- Created a new chain called `zk_chain_1` and set it as your default chain.
- Set the chain id to `271`.
- Chose the default wallet configuration.
Expand Down Expand Up @@ -161,7 +163,7 @@ To summarize, the `init` command:
- Sets up a database for the default chain (in this case `zk_chain_1`).
- Deploys a paymaster contract and some test ERC20 contracts (if selected) to use for development.
You can find the paymaster contract used in the `zksync-era` repo in `contracts/l2-contracts/contracts/TestnetPaymaster.sol`,
You can find the paymaster contract deployed to your chain in the `zksync-era` repo in `contracts/l2-contracts/contracts/TestnetPaymaster.sol`,
and the deployed address inside `my_elastic_chain/chains/zk_chain_1/configs/contracts.yaml` at `l2:testnet_paymaster_addr`.
For the ERC20 contracts, you can find the deployed addresses inside `my_elastic_chain/configs/erc20.yaml`.
Expand Down Expand Up @@ -215,6 +217,8 @@ For testing purposes, we'll use one of the rich wallets as both the sender and r
? Recipient address on L2 0x36615Cf349d7F6344891B1e7CA7C72883F5dc049
```
You can find a full list of rich wallet addresses and their private keys in the [ZKsync docs](https://docs.zksync.io/build/test-and-debug/in-memory-node#pre-configured-rich-wallets).
To see that it worked, let's check the balance of that address on `zk_chain_1`:
```bash
Expand Down
20 changes: 13 additions & 7 deletions content/tutorials/custom-zk-chain/20.customizing-your-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description: Create a ZK chain with a custom ERC20 base token.
One way you can customize your ZK chain is by changing the base token used for gas from ETH to an ERC20 token.
Let's try customizing a new chain by using a custom ERC20 base token.

For the first release of the ZK stack, the base tokens you can use for your chain must be whitelisted.
With the initial release of ZK stack, base tokens must be whitelisted for use as base token for a chain.
The whitelisted addresses are stored and checked in the `BridgeHub` contract on the L1.
In the future it will be possible to add a new token in a permissionless process.

Expand Down Expand Up @@ -82,7 +82,8 @@ Next, create a `.env` file with:
touch .env
```

and add the `WALLET_PRIVATE_KEY` environment variable with the private key of the rich wallet we've been using:
and add the `WALLET_PRIVATE_KEY` environment variable with the private key of the rich wallet we've been using
so that we can deploy using a pre-funded address:

```env
WALLET_PRIVATE_KEY=0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110
Expand Down Expand Up @@ -162,7 +163,11 @@ You can find the address for the governor in `my_elastic_chain/configs/wallets.y
Run the command below to use `cast` to transfer some of your ERC20 tokens to the governor's address on the L1.

```bash
cast send 0xYOUR_TOKEN_ADDRESS "transfer(address,uint256)" 0x_YOUR_GOVERNOR_ADDRESS 5000000000000000000 --private-key 0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110 --rpc-url http://localhost:8545 --gas-price 30000000000
cast send 0xYOUR_TOKEN_ADDRESS "transfer(address,uint256)" \
<0x_YOUR_GOVERNOR_ADDRESS> 5000000000000000000 \
--private-key 0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110 \
--rpc-url http://localhost:8545 \
--gas-price 30000000000
```

To verify that this worked, check the balance of the governor's address:
Expand Down Expand Up @@ -296,7 +301,8 @@ npx zksync-cli bridge deposit \
? Recipient address on L2 0x36615Cf349d7F6344891B1e7CA7C72883F5dc049
```

If you run the previous command to check the base token balance again, note how the balance is still `5`. Because ETH is no longer the base token, it has a different token address on L2 you will need to reference.
If you run the previous command to check the base token balance again, note how the balance is still `5`.
Because ETH is no longer the base token, it has a different token address on L2 you will need to reference.
To find the L2 token address for ETH, you can use the `l2TokenAddress` method available through `zksync-ethers`.

To try this out, open the `zk-chain-test` folder from the previous section,
Expand Down Expand Up @@ -334,19 +340,19 @@ npx hardhat run scripts/checkBalance.ts
You should see the output below showing the same amount of ETH you bridged:
```shell
L2 ETH Address: 0x_YOUR_ETH_TOKEN_ADDRESS
L2 ETH Address: <0x_YOUR_ETH_TOKEN_ADDRESS>
L2 ETH Balance 🎉: 20000000000000000000n
```
## Switching between chains and shutting down the ecosystem
You can switch in between different chains without losing any state by shutting down the chain server and running the command below:
You can switch in between different chains without losing any state by shutting down the chain server and then running the command below:
```bash
zk_inception ecosystem change-default-chain
```
Now when you run `zk_inception server`, the new default chain will start again with the same state.
Now when you restart the server with `zk_inception server`, the new default chain's node will start again with the same 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 Down

0 comments on commit 326b486

Please sign in to comment.