Deploy a ZK Stack Validium with Avail DA
Discover how to utilize Avail as a data availability layer.
Introduction
localhost.
In this guide, you will go over the following:
Setting up your developer environment
| Software | Version |
|---|---|
| Node.js | Latest LTS Version |
| Git | OS Default |
| Docker | Latest |
| Docker Compose | Latest |
| Yarn | v1.22.19 |
| cargo-nextest | Latest |
| sqlx-cli | Latest |
| Foundry | Latest |
| Postgres | Latest |
zksync-era repository.
Installation commands are based on Ubuntu 20.04 LTS:
The below installation commands are taken from setup-dev.md from the zksync-era repository. For any more troubleshooting, please refer to the original repository.
# For VMs only! They don't have SSH keys, so we override SSH with HTTPS
git config --global url."https://github.com/".insteadOf git@github.com:
git config --global url."https://".insteadOf git://
# Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# NVM
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
# All necessary stuff
sudo apt-get update
sudo apt-get install -y build-essential pkg-config cmake clang lldb lld libssl-dev libpq-dev apt-transport-https ca-certificates curl software-properties-common
# Install docker
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
sudo apt install docker-ce
sudo usermod -aG docker ${USER}
# Start docker.
sudo systemctl start docker
## You might need to re-connect (due to usermod change).
# Node & yarn
nvm install 20
# Important: there will be a note in the output to load
# new paths in your local session, either run it or reload the terminal.
npm install -g yarn
yarn set version 1.22.19
# For running unit tests
cargo install cargo-nextest
# SQL tools
cargo install sqlx-cli --version 0.8.1
# Foundry ZKsync
curl -L https://raw.githubusercontent.com/matter-labs/foundry-zksync/main/install-foundry-zksync | bash
foundryup-zksync
# Non CUDA (GPU) setup, can be skipped if the machine has a CUDA installed for provers
# Don't do that if you intend to run provers on your machine. Check the prover docs for a setup instead.
echo "export ZKSYNC_USE_CUDA_STUBS=true" >> ~/.bashrc
# You will need to reload your `*rc` file hereInstalling & running the ZK Stack
1. Install ZK Stack CLI
zkstack, run the following command:
curl -L https://raw.githubusercontent.com/matter-labs/zksync-era/main/zkstack_cli/zkstackup/install | bash
source ~/.bashrc
zkstackup2. Clone the zksync-era repository from github
git clone git@github.com:matter-labs/zksync-era.git
cd zksync-era- Install submodules:
git submodule update --init --recursive 3. Running the containers
- We can start running the containers and ecosystem by first cleaning the docker containers and then running the following command:
zkstack dev clean allzkstack. The great thing about this is that zkstack handles everything on its own. If you encounter any errors, just make sure your ports are not busy and the observability feature is disabled during container setting up.
zkstack containers4. Initialize Elastic Chain ecosystem
- We need to create an Elastic Chain ecosystem now. We will choose all the default options.
zkstack ecosystem init- Once we have successfully initialized an elastic chain ecosystem, we can create new chains and can choose to create a Validium when prompted. For simplicity, we will choose the default options.
zkstack chain create- Once we have created the chain, we have to finally initialize it and deploy the contracts of the ZK chain:
zkstack chain init5. Configure Avail DA
Note
BEFORE YOU BEGIN
Before configuring Avail DA, complete these essential steps:
Before configuring Avail DA, complete these essential steps:
Create an Avail Account: Set up your account to interact with the Avail networkGet Testnet Tokens: Obtain AVAIL tokens on the Turing testnet for transactionsCreate an AppID: Required to identify your application on the Avail network
Full Client
Using the full client requires you to create an AppID and maintain the Avail balance in your designated data submission account.- Add the following to your chain's general config:
zksync-era/chains/$CHAIN_NAME/configs/general.yaml
da_client:
avail:
bridge_api_url: https://turing-bridge-api.avail.so
timeout_ms: 7200000
full_client:
api_node_url: wss://turing-rpc.avail.so/ws
app_id: YOUR_APP_IDNote
RPC Access
To obtain a reliable RPC endpoint for production use, please reach out to our external partners. They provide dedicated endpoint access with enhanced reliability and performance for production-ready infrastructure.
To obtain a reliable RPC endpoint for production use, please reach out to our external partners. They provide dedicated endpoint access with enhanced reliability and performance for production-ready infrastructure.
da_client:
avail:
bridge_api_url: https://bridge-api.avail.so
timeout_ms: 7200000
full_client:
api_node_url: wss://mainnet.avail-rpc.com
app_id: YOUR_APP_ID- Add the following to your chain's secrets config:
zksync-era/chains/$CHAIN_NAME/configs/secrets.yaml
da:
avail:
seed_phrase: YOUR_SEED_PHRASEGas Relay
The gas relay API is in private beta. Using the gas relay allows you to post data to Avail using a relayer and pay fees in a different token (only if supported) without needing to maintain a balance. It is recommended to create an AppID to use within the gas relay service. Please contact the Avail team if you want access to the gas relay API.- Add the following to your chain's general config:
zksync-era/chains/$CHAIN_NAME/configs/general.yaml
da_client:
avail:
bridge_api_url: https://turing-bridge-api.avail.so
timeout_ms: 7200000
gas_relay:
gas_relay_api_url: https://staging.turbo-api.availproject.org
max_retries: 3da_client:
avail:
bridge_api_url: https://bridge-api.avail.so
timeout_ms: 7200000
gas_relay:
gas_relay_api_url: COMING_SOON
max_retries: 3- Add the following to your chain's secrets config:
zksync-era/chains/$CHAIN_NAME/configs/secrets.yaml
da:
avail:
gas_relay_api_key: YOUR_API_KEY6. Run ZK chain
localhost:3150.
zkstack server --chain $CHAIN_NAMEHow is this guide?