From 26a9938899a4cbf30b2a113f128c3dad78ac5e7b Mon Sep 17 00:00:00 2001 From: Sarah Schwartz <58856580+sarahschwartz@users.noreply.github.com> Date: Thu, 15 Aug 2024 08:14:59 -0600 Subject: [PATCH] docs: add ZK chain tutorial (#36) * docs: add zk chain tutorial * docs: cleanup zk chain tutorial * Apply suggestions from code review Co-authored-by: Sabrina * docs: add review suggestions * docs: minor fixes and feedback * docs: minor fixes and add feedback * docs: apply feedback to add more context * docs: use allowlist * docs: address feedback * fix: minor fixes * Apply suggestions from code review Co-authored-by: Sabrina * docs: address feedback * Apply suggestions from code review Co-authored-by: Sabrina * docs: address feedback --------- Co-authored-by: Sabrina --- content/tutorials/custom-zk-chain/10.index.md | 277 ++++++++++++ .../20.customizing-your-chain.md | 396 ++++++++++++++++++ content/tutorials/custom-zk-chain/_dir.yml | 26 ++ .../tutorials/guide-dipdup-indexer/_dir.yml | 2 +- cspell-config/cspell-blockchain.txt | 2 + cspell-config/cspell-misc.txt | 1 + 6 files changed, 703 insertions(+), 1 deletion(-) create mode 100644 content/tutorials/custom-zk-chain/10.index.md create mode 100644 content/tutorials/custom-zk-chain/20.customizing-your-chain.md create mode 100644 content/tutorials/custom-zk-chain/_dir.yml diff --git a/content/tutorials/custom-zk-chain/10.index.md b/content/tutorials/custom-zk-chain/10.index.md new file mode 100644 index 0000000..3d40d9a --- /dev/null +++ b/content/tutorials/custom-zk-chain/10.index.md @@ -0,0 +1,277 @@ +--- +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: + +- You'll set up a local **Elastic Chain ecosystem** +- You'll create a standard **ZK chain** +- You'll deploy a smart contract to your local **ZK chain** +- You'll create a second ZK chain that uses a **custom ERC20 base token** + +## Prerequisites + +- Make sure your machine satisfies the [system + requirements](https://github.com/matter-labs/era-compiler-solidity/tree/main#system-requirements). +- If you aren't already familiar with deploying smart contracts on ZKsync Era, please refer to the first section of the [quickstart tutorial](https://docs.zksync.io/build/start-coding/quick-start/deploy-your-first-contract). +- 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). + +::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_inception` CLI + +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: + +```bash +cargo install --git https://github.com/matter-labs/zksync-era/ \ +--locked zk_inception --force +``` + +::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). +:: + +## Setting up the Elastic Chain ecosystem + +An Elastic Chain ecosystem is, in short, a system to manage multiple ZK chains. +The vision for the Elastic Chain is an ever-expanding network of ZK rollups, secured by math and natively interoperable under a uniform, intuitive UX. +New chains can be registered to the ecosystem to scale applications and communities as needed, making it "elastic". + +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. + +The first step is to create a new ecosystem with the `ecosystem create` command. + +::callout{icon="i-heroicons-light-bulb"} +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 +``` + +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 + +┌ ZKsync toolbox +│ +◇ What do you want to name the ecosystem? +│ my_elastic_chain +│ +◇ Select the origin of zksync-era repository +│ Clone for me (recommended) +│ +◇ Select the L1 network +│ Localhost +│ +◇ What do you want to name the chain? +│ zk_chain_1 +│ +◇ Whats the chain id? +│ 271 +│ +◇ Select how do you want to create the wallet +│ Localhost +│ +◇ Select the prover mode +│ NoProofs +│ +◇ Select the commit data generator mode +│ Rollup +│ +◇ Select the base token to use +│ Eth +│ +◇ Do you want to start containers after creating the ecosystem? +│ Yes +``` + +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, the CLI will automatically set this up and run it for you!). + We need to do this because our ecosystem contracts need to get deployed on an L1, so we can either use a local L1 chain or the Sepolia testnet. + For development purposes, it's easier to use a local L1 chain. +- 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. + This option will use known mnemonic phrases to generate the `wallets.yaml` configuration files for the ecosystem and chain. + You can also choose `random` to randomly generate the wallets, + `empty` to generate a config file with empty values for the wallets, + or `in-file` to set the location of the config to an existing file. +- Selected to not use proofs, which makes testing more lightweight. +- Chose a standard rollup for the data availability. + You can read more about data availability options for ZK chains in the + [ZK chains](https://docs.zksync.io/zk-stack/concepts/zk-chains#data-availability-da) docs. +- Selected ETH to use as the base token. +- Started the containers for the ecosystem in Docker. + +Inside the generated `my_elastic_chain` folder, you should now have the following contents: + +- `ZkStack.yaml`: a configuration file for the ecosystem. +- `chains`: a folder with configurations for each chain created. +- `configs`: configuration for the deployments and wallets. +- `volumes`: dependencies for running local nodes. +- `zksync-era`: a clone of the `zksync-era` repository. +- `docker-compose.yml`: a Docker compose file to start up a local environment. + +## Deploying the ecosystem + +You've just set up your ecosystem and chain, and have two Docker containers running: +a postgres database for your chain, and a reth node for the local L1 chain. + +The L1 chain is already running, but your ecosystem and chain aren't deployed yet. +The next step is to deploy your ecosystem contracts to the L1 and register your chain to the ecosystem. + +Move into the ecosystem folder: + +```bash +cd my_elastic_chain +``` + +Next, run the `ecosystem init` command below to deploy the ecosystem: + +```bash +zk_inception ecosystem init --dev +``` + +The `--dev` flag will choose the default options for development. + +::callout{icon="i-heroicons-light-bulb"} +If you have any issues at this step, try reinstalling the dependencies at the top. +:: + +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: + +- Checks to see if your environment has the necessary dependencies. +- Compiles and deploys all of the necessary contracts for the ecosystem. +- Deploys `zk_chain_1` to the ecosystem. +- Sets up a database for the default chain (in this case `zk_chain_1`). +- Deploys a paymaster contract and some test ERC20 contracts to use for development. + +You can find the paymaster contract code deployed to your chain in the `zksync-era` repo in [`contracts/l2-contracts/contracts/TestnetPaymaster.sol`](https://github.com/matter-labs/era-contracts/blob/main/l2-contracts/contracts/TestnetPaymaster.sol), +and the deployed address inside `/chains/zk_chain_1/configs/contracts.yaml` at `l2:testnet_paymaster_addr`. + +For the ERC20 contracts, you can find the deployed addresses inside `/configs/erc20.yaml`. + +### Understanding the chain configs + +Running the `init` command will also modify your chain configuration files in the ecosystem folder. + +The main configuration file for `zk_chain_1` can be found in `/chains/zk_chain_1/ZkStack.yaml`. +It contains the most basic configurations for the chain. + +Inside `/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. + +::callout{icon="i-heroicons-exclamation-triangle" color="amber"} +Never commit your private keys or sensitive secrets. +:: + +### Starting the chain server + +The last step here is to start a server for `zk_chain_1`: + +```bash +zk_inception server +``` + +With this, your L1 chain should be running at port `8545`, and the `zk_chain_1` node should be running at port `3050`. + +## Funding a wallet on your chain + +Because you chose to use a local reth node for your L1 and selected ETH as the base asset, +you have access to several rich wallets on the L1 that you can use to bridge ETH to `zk_chain_1`. + +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). + +::callout{icon="i-heroicons-exclamation-triangle" color="amber"} +Never use these wallets in production or send real funds to them. +:: + +Open a new terminal and run the command below to bridge some ETH to `zk_chain_1` using ZKsync CLI: + +```bash +npx zksync-cli bridge deposit --rpc=http://localhost:3050 --l1-rpc=http://localhost:8545 +``` + +For testing purposes, we'll use one of the rich wallets as both the sender and recipient: + +```shell +? Amount to deposit 10 +? Private key of the sender 0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110 +? Recipient address on L2 0x36615Cf349d7F6344891B1e7CA7C72883F5dc049 +``` + +To see that it worked, let's check the balance of that address on `zk_chain_1`: + +```bash +npx zksync-cli wallet balance \ +--address 0x36615Cf349d7F6344891B1e7CA7C72883F5dc049 \ +--rpc http://localhost:3050 +``` + +Now this address has ETH available on `zk_chain_1` to use for testing. + +## Deploying a contract to chain 1 + +Now that your chain is deployed and your wallet is funded, let's create a template contract and deploy it to `zk_chain_1`: + +Move out of your ecosystem folder and initialize a new hardhat project using ZKsync CLI: + +```bash +npx zksync-cli@latest create --template qs-hello-zksync zk-chain-test +cd zk-chain-test +``` + +Use the same private key for the rich wallet: + +```shell +? Private key of the wallet responsible for deploying contracts (optional) +0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110 +``` + +In the `hardhat.config.ts` file, change the default network on line 6 to `dockerizedNode`, +which is already configured to connect to the local chain node running on port `3050`: + +```bash +defaultNetwork: "dockerizedNode", +``` + +Finally, compile the contract and run the deploy script: + +```bash +yarn compile && yarn deploy +``` + +Nice - you just deployed a contract to your own local ZK chain! + +Next, let's take a look at customizing a chain. diff --git a/content/tutorials/custom-zk-chain/20.customizing-your-chain.md b/content/tutorials/custom-zk-chain/20.customizing-your-chain.md new file mode 100644 index 0000000..1c85ba6 --- /dev/null +++ b/content/tutorials/custom-zk-chain/20.customizing-your-chain.md @@ -0,0 +1,396 @@ +--- +title: Customizing your ZK chain +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, custom ERC20 tokens must be added to an allowlist for use as a base token for a chain. +The allowed addresses are stored and checked in the `BridgeHub` contract on the L1. +In the future it will be possible to deploy a chain that uses a new custom base token in a permissionless process. + +For now, you have the ability to add any tokens to the allowlist in your local ecosystem. + +The overall flow for setting up a local chain with a custom base token looks like this: + +1. Deploy an ERC20 token to the L1. +1. Create your new chain that uses the ERC20 token and set it as the default. +1. Send ERC20 tokens to the ecosystem and chain governor addresses on the L1. +1. Initialize the new chain in the ecosystem. +1. Bridge tokens from the L1 to your new chain. + +## Deploying an ERC20 token + +For the first step of this flow, let's make a new hardhat project. + +### Setup + +Move out of your previous folder and make a new folder for the ERC20 token contract. + +```bash +mkdir base-token-contract +cd base-token-contract +``` + +Then, run the `hardhat init` command to generate a new project: + +```bash +npx hardhat init +``` + +Select the option **Create a Typescript project** and accept the default options for everything else. + +Run the command below to install the necessary dependencies: + +::code-group + +```bash [npm] +npm i -D typescript ts-node @openzeppelin/contracts @nomicfoundation/hardhat-ethers @typechain/ethers-v6 @typechain/hardhat typechain ethers dotenv +``` + +```bash [yarn] +yarn add -D typescript ts-node @openzeppelin/contracts @nomicfoundation/hardhat-ethers @typechain/ethers-v6 @typechain/hardhat typechain ethers dotenv +``` + +:: + +### Configuring Hardhat + +Once installed, replace your existing config in `hardhat.config.ts` with the config below: + +```ts +import { HardhatUserConfig } from "hardhat/config"; +import "@nomicfoundation/hardhat-toolbox"; + +import dotenv from "dotenv"; +dotenv.config(); + +const config: HardhatUserConfig = { + solidity: "0.8.20", + networks: { + localRethNode: { + url: "http://localhost:8545", + accounts: [process.env.WALLET_PRIVATE_KEY as any], + }, + }, +}; + +export default config; +``` + +Now hardhat is configured to connect to our local reth node (the L1) running at local port `8545`. +For the inital release of the ZK stack, we have to deploy the token to the L1 and bridge to our ZK chain later. +However, in the future this may change. + +Next, create a `.env` file with: + +```bash +touch .env +``` + +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 +``` + +### Deploying an ERC20 Contract + +Now that we've configured hardhat and the deployer wallet, let's add the contract and deploy script. +Rename the example generated contract file to `CustomBaseToken.sol`: + +```bash +mv contracts/Lock.sol contracts/CustomBaseToken.sol +``` + +Open the `CustomBaseToken.sol` file and replace the example contract with the ERC20 contract below: + +```solidity +// SPDX-License-Identifier: Unlicensed +pragma solidity ^0.8.20; + +import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; +import "@openzeppelin/contracts/access/Ownable.sol"; +import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol"; + +contract CustomBaseToken is ERC20, Ownable, ERC20Burnable { + constructor(string memory name, string memory symbol) ERC20(name, symbol) Ownable(msg.sender) { + _mint(msg.sender, 100 * 10 ** decimals()); + } + + function mint(address to, uint256 amount) public onlyOwner { + _mint(to, amount); + } +} +``` + +Next, let's update the ignition module to deploy the ERC20 contract. +Rename the module file with the command below: + +```bash +mv ignition/modules/Lock.ts ignition/modules/CustomBaseToken.ts +``` + +Then, replace the module file with the code below: + +```ts +import { buildModule } from "@nomicfoundation/hardhat-ignition/modules"; + +const CustomBaseTokenModule = buildModule("CustomBaseTokenModule", (m) => { + const tokenName = m.getParameter("name", "ZK Base Token"); + const tokenSymbol = m.getParameter("symbol", "ZKBT"); + + const baseToken = m.contract("CustomBaseToken", [tokenName, tokenSymbol]); + + return { baseToken }; +}); + +export default CustomBaseTokenModule; +``` + +To run the module and deploy the token contract, run: + +```bash +npx hardhat ignition deploy ./ignition/modules/CustomBaseToken.ts --network localRethNode +``` + +Select `y` to confirm to deploy the contract to the `localRethNode`. +After deploying, the token contract address should be logged in your console. + +The constructor function in the contract should have minted tokens to the deployer address. +Let's verify that the tokens were minted to the deployer address using the Foundry `cast` CLI: + +```bash +cast balance --erc20 <0xYOUR_TOKEN_ADDRESS> 0x36615Cf349d7F6344891B1e7CA7C72883F5dc049 \ +--rpc-url http://localhost:8545 +``` + +## Creating a new chain + +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: + +```bash +zk_inception chain create +``` + +This time, use the answers below: + +```bash +$ zk_inception chain create + +┌ ZKsync toolbox +│ +◇ What do you want to name the chain? +│ custom_zk_chain +│ +◇ What's the chain id? +│ 272 +│ +◇ Select how do you want to create the wallet +│ Localhost +│ +◇ Select the prover mode +│ NoProofs +│ +◇ Select the commit data generator mode +│ Rollup +│ +◇ Select the base token to use +│ Custom +│ +◇ What is the token address? +│ <0x_YOUR_TOKEN_ADDRESS> +│ +◇ What is the base token price nominator? +│ 1 +│ +◇ What is the base token price denominator? +│ 1 +│ +◇ Set this chain as default? +│ Yes +``` + +The base token nominator and denominator are used to define the relation of the base token price with ETH. +For example, if we set the nominator to 20 and the denominator to 1, together the relation is 20/1, +this would mean that 20 tokens would be given the equivalent value as 1 ETH for gas. +For testing purposes, we'll just use a 1:1 ratio. + +### Funding the governor addresses + +Now that you have some tokens and created a new chain, +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. +For the _ecosystem governor_, you can find the address in `/configs/wallets.yaml` under `governor`. + +The second governor address you need to fund is for the _chain governor_. +The chain governor address can be found in `/chains/custom_zk_chain/configs/wallets.yaml` also under `governor`. + +Run the command below **twice** (once for each governor address) 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> 1000000000000000000 \ +--private-key 0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110 \ +--rpc-url http://localhost:8545 \ +--gas-price 30000000000 +``` + +To verify that this worked, check the balance of both governor addresses: + +```bash +cast balance --erc20 <0xYOUR_TOKEN_ADDRESS> \ +<0x_YOUR_GOVERNOR_ADDRESS> \ +--rpc-url http://localhost:8545 +``` + +### Initializing the chain + +::callout{icon="i-heroicons-exclamation-triangle" color="amber"} +Make sure the server for `zk_chain_1` that you started in the previous section is shut down. +:: + +Next, initialize the chain in the ecosystem with the command below, and select the default options for the prompts. + +```bash +zk_inception 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 +``` + +## Bridging the base token to your chain + +The last step is to bridge some ERC20 tokens from the L1 to the new chain. +Base tokens can not be minted on the L2 without being backed by the corresponding L1 amount. In the future, there will be more flexibility for this. + +Open a new terminal and use ZKsync CLI to bridge the tokens with the command below: + +```bash +npx zksync-cli bridge deposit --token <0x_YOUR_TOKEN_ADDRESS> \ +--rpc=http://localhost:3050 \ +--l1-rpc=http://localhost:8545 +``` + +```shell +? Amount to deposit 5 +? Private key of the sender 0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110 +? Recipient address on L2 0x36615Cf349d7F6344891B1e7CA7C72883F5dc049 +``` + +To verify that this worked, let's check the new balance of our address on the L2 chain: + +```bash +npx zksync-cli wallet balance \ +--address 0x36615Cf349d7F6344891B1e7CA7C72883F5dc049 \ +--rpc http://localhost:3050 +``` + +Note that we aren't checking for any specific token address here. +The CLI will display the amount as ETH, but in reality, it's our bridged ERC20 tokens. + +And that's it! You are now running a local ZK chain that uses a custom ERC20 base token. +You can follow the steps in the previous section to deploy a contract to the new chain. + +## Bridging ETH to your chain + +If your ERC20 token bridged to the L2 "acts" like ETH, then what happens if you bridge ETH to your custom chain? + +The answer is that if you try to bridge regular ETH to this chain, it will just use a different token contract address. + +You can try this out by depositing ETH from the L1 to this new chain: + +```bash +npx zksync-cli bridge deposit \ +--rpc=http://localhost:3050 \ +--l1-rpc=http://localhost:8545 +``` + +```shell +? Amount to deposit 20 +? Private key of the sender 0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110 +? 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. +To find the L2 token address for ETH, you can use the `l2TokenAddress` method available through `zksync-ethers`. + +To try this out, open your hardhat project `zk-chain-test` from the previous section, +and run the commands below to create a new script file: + +```bash +mkdir scripts +touch scripts/checkBalance.ts +``` + +Next, copy and paste the script below into the `checkBalance.ts` file: + +```ts +import { ETH_ADDRESS_IN_CONTRACTS } from "zksync-ethers/build/utils.js"; +import { getWallet } from "../deploy/utils"; + +async function main(){ + const wallet = getWallet(); + const l2ETHAddress = await wallet.l2TokenAddress(ETH_ADDRESS_IN_CONTRACTS); + console.log("L2 ETH Address:", l2ETHAddress); + + const balance = await wallet.getBalance(l2ETHAddress); + console.log("L2 ETH Balance 🎉:", balance); +} + +main(); +``` + +Run the script with the `hardhat run` command: + +```bash +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 Balance 🎉: 20000000000000000000n +``` + +## Switching between chains and shutting down the ecosystem + +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 +``` + +Now when you start the server with `zk_inception 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: + +```bash +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. Redeploy your ERC20 contract to the L1. +1. Update the base token address in `/chains/custom_zk_chain/configs/contracts.yaml` under `l1.base_token_addr` and in + `/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. Bridge ERC20 tokens from the L1 to L2. diff --git a/content/tutorials/custom-zk-chain/_dir.yml b/content/tutorials/custom-zk-chain/_dir.yml new file mode 100644 index 0000000..42ac80c --- /dev/null +++ b/content/tutorials/custom-zk-chain/_dir.yml @@ -0,0 +1,26 @@ +title: Building a Custom ZK Chain +featured: true +authors: + - name: MatterLabs + url: https://matter-labs.io + avatar: https://avatars.githubusercontent.com/u/42489169?s=200&v=4 +github_repo: https://github.com/ZKsync-Community-Hub +tags: + - elastic chain + - zk chain + - tutorial +summary: Create, customize, and run your first ZK chain locally. +description: + In this tutorial, you will get familiar with the ZK Inception CLI. You will create a local Elastic Chain ecosystem and + deploy a contract to a ZK chain. Next, you will create a new ZK chain that uses a custom ERC20 base token. +what_you_will_learn: + - How to create and locally run an Elastic Chain ecosystem. + - How to create a ZK chain and deploy a contract to it. + - How to setup a ZK chain with a custom base token. +updated: 2024-08-14 +tools: + - zk_inception + - hardhat + - cast + - zksync-cli + - zksync-ethers diff --git a/content/tutorials/guide-dipdup-indexer/_dir.yml b/content/tutorials/guide-dipdup-indexer/_dir.yml index 2af8361..a6dc21b 100644 --- a/content/tutorials/guide-dipdup-indexer/_dir.yml +++ b/content/tutorials/guide-dipdup-indexer/_dir.yml @@ -1,5 +1,5 @@ title: Create an indexer with DipDup -featured: true +featured: false authors: - name: DipDup url: https://dipdup.io diff --git a/cspell-config/cspell-blockchain.txt b/cspell-config/cspell-blockchain.txt index 9e1a797..0fda76b 100644 --- a/cspell-config/cspell-blockchain.txt +++ b/cspell-config/cspell-blockchain.txt @@ -41,6 +41,8 @@ Pyth Pythnet Rabby regenesis +Reth +reth satoshi sepolia Sepolia diff --git a/cspell-config/cspell-misc.txt b/cspell-config/cspell-misc.txt index 2646c5f..01575bd 100644 --- a/cspell-config/cspell-misc.txt +++ b/cspell-config/cspell-misc.txt @@ -97,6 +97,7 @@ vue Vue Zerion zext +ZKBT ZKEVM zkout zksolc