Launch a ZKsync chain
Prerequisites
Make sure you have Rust and version
1.5.1 of anvil via
foundry installed.
Local Chain Setup
To setup a local environment for testing, clone the zksync-os-server repo:
git clone https://github.com/matter-labs/zksync-os-server.git
Then move into the repo and run the command below to start a local environment with one L2 chain using protocol version 30.2.
cd zksync-os-server
./run_local.sh ./local-chains/v30.2/default
local-chains folder.The first time running this can take a few minutes for the dependencies to compile.
You should now have two local chains running:
- a local L1 chain running at port
8545 - a local L2 chain running at port
3050(chain ID6565)
Note that once you end this process, the history of each chain will be completely erased. These are in-memory nodes, so they do not persist any storage of the chains.
Funding a test account
The L1 chain has access to all of the default rich wallets configured with anvil.
However these addresses do not yet have funds bridged to them on the L2 chains.
Before using your chain, use the command below to bridge funds from a local rich wallet on the L1 to the L2 from inside the zksync-os-server repo.
Example: Fund a wallet on chain 6565
Run the command below to bridge funds from a local rich wallet on the L1 chain to the L2 chain.
Replace <0x_YOUR_BRIDGEHUB_ADDRESS> with the bridgehub_address configured in local-chains/v30.2/default/config.yaml.
cargo run -p zksync_os_generate_deposit -- \
--bridgehub <0x_YOUR_BRIDGEHUB_ADDRESS> \
--chain-id 6565 \
--l1-rpc-url http://localhost:8545 \
--private-key 0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110 \
--amount 1
After running, 0x36615Cf349d7F6344891B1e7CA7C72883F5dc049 will have 1 ETH available on the L2 chain.
Using your chain RPC
Your server contains both HTTPS as well as WebSocket (WS) RPC services that are fully web3 compatible (and contain some extra ZK Stack functionalities). Learn more on the API reference page.
Using a Block Explorer
A block explorer is a web-app that lets you view and inspect transactions, blocks, contracts and more. A free open source block explorer is available for your ZKsync chain.