Skip to content

Commit

Permalink
docs: minor fixes and add feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahschwartz committed Aug 7, 2024
1 parent 7a7c0b3 commit e21c41f
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 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.

With the initial release of ZK stack, base tokens must be whitelisted for use as base token for a chain.
With the initial release of ZK stack, base tokens must be whitelisted for use as a 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 All @@ -16,7 +16,7 @@ For now, you have the ability to whitelist tokens in your local ecosystem.
The overall flow for setting up a local chain with a custom ERC20 base token looks like this:

1. Deploy an ERC20 token to the L1.
1. Send ERC20 tokens to the governor address on the L1.
1. Send ERC20 tokens to the ecosystem and chain governor addresses on the L1.
1. Create your new chain that uses the ERC20 token and set it as the default.
1. Initialize the new chain in the ecosystem.
1. Bridge tokens from the L1 to your new chain.
Expand Down Expand Up @@ -157,14 +157,16 @@ cast balance --erc20 <0xYOUR_TOKEN_ADDRESS> 0x36615Cf349d7F6344891B1e7CA7C72883F
--rpc-url http://localhost:8545
```

Now that you have some tokens, the next step is to send some to the governor's address on the L1 so that you can register and deploy your chain.
You can find the address for the governor in `my_elastic_chain/configs/wallets.yaml` under `governor`.
Now that you have some tokens, the next step is to send some to each of the governor's addresses for the ecosystem and chain on the L1.
This will allow you to register and deploy your chain, and deploy the paymaster.
You can find the address for the ecosystem governor in `my_elastic_chain/configs/wallets.yaml` under `governor`.
The chain governor address can be found in `my_elastic_chain/chains/custom_zk_chain/configs/wallets.yaml` under `governor`.

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 \
cast send <0xYOUR_TOKEN_ADDRESS> "transfer(address,uint256)" \
<0x_YOUR_GOVERNOR_ADDRESS> 1000000000000000000 \
--private-key 0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110 \
--rpc-url http://localhost:8545 \
--gas-price 30000000000
Expand All @@ -180,7 +182,7 @@ cast balance --erc20 <0xYOUR_TOKEN_ADDRESS> \

## Creating a new chain

Now that your ERC20 token is deployed and the governor's address is funded with that token, you can create a new chain.
Now that your ERC20 token is deployed and the governor addresses are funded with that token, you can create a new chain.

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

Expand Down Expand Up @@ -236,12 +238,9 @@ For testing purposes, we'll just use a 1:1 ratio.
Next, initialize the chain in the ecosystem with:

```bash
zk_inception chain init
zk_inception chain init --dev
```

This time select *no* for the option to deploy a paymaster contract in order to avoid having to fund another address with your ERC20 base token.
Use the default answers for all other prompts.

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

```bash
Expand All @@ -263,7 +262,7 @@ npx zksync-cli bridge deposit --token <0x_YOUR_TOKEN_ADDRESS> \

```shell
? Amount to deposit 5
? Private key of the sender 0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110
? Private key of the sender 0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110
? Recipient address on L2 0x36615Cf349d7F6344891B1e7CA7C72883F5dc049
```

Expand Down Expand Up @@ -297,7 +296,7 @@ npx zksync-cli bridge deposit \

```shell
? Amount to deposit 20
? Private key of the sender 0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110
? Private key of the sender 0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110
? Recipient address on L2 0x36615Cf349d7F6344891B1e7CA7C72883F5dc049
```

Expand Down Expand Up @@ -367,8 +366,7 @@ To restart the ecosystem and run your custom ZK chain again, follow the steps be
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 the governor address.
1. Initialize the ecosystem with `zk_inception ecosystem init` and choose to not deploy the Paymaster or ERC20 test tokens
(this requires funding another 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. Bridge ERC20 tokens from the L1 to L2.

0 comments on commit e21c41f

Please sign in to comment.