Deploy an L3 using Avail
In this guide, we will walk through the process of deploying a Bitcoin Appchain (L3) on Citrea using the OP Stack, with Avail as the data availability layer.
The following steps are appropriately modified from the Optimism documentation.
Prerequisites
Avail Network Info (RPC Endpoints)
Docker (for running the Avail DA Server with docker-compose)
Foundry for contract deployment
We recommend opening a separate folder in your filesystem for the rest of this guide.
Appchains require strong hardware to function properly. For demo purposes, we used a machine with AMD EPYC 9124 @ 3.71GHz and 128 GB of RAM.
Step 1: Set up Avail DA prerequisites
Step 1.1 Create an Avail account (seed)
To submit data to Avail DA, you will need an Avail account (seed phrase). Follow the steps here.
Step 1.2 Get funds to your address
To write data into Avail DA, your Avail account must be funded with AVAIL tokens. Follow the steps here.
Step 1.3 Create an AppID
Create an AppID on Avail DA and save the AppID value. Follow the steps here.
Step 2: DA Server Setup
This introduces a sidecar DA Server for Optimism that interacts with Avail DA for posting and retrieving data.
Step 2.1 Build Avail DA Server
Let's clone the avail-alt-da-server repository first and build the avail-da-server binary:
This will create the avail-da-server binary in the bin folder.
Step 2.2 Run avail-da-server binary (Option 1)
Run your DA sidecar (use an Avail RPC endpoint from the Network Info page):
Step 2.3 Run using docker (Option 2)
Copy
.env.exampleto.env. Fill the values inside.Run the following commands:
Step 3: Setup Optimism repositories and configure environment
Step 3.1: Clone repositories
Clone op-geth and Optimism mono-repository, then checkout to v1.9.2 for development purposes:
Step 3.2: Setup environment
Then, let's setup our environment using the .envrc file (alternatively you can set them in your shell):
If you're using direnv, run:
Step 3.3: Run configuration scripts
Navigate to the optimism directory and generate the configuration:
Later in the same folder, let's run the deployment script using forge to deploy the necessary contracts on Citrea:
And also run the L3 genesis configuration script:
Step 4: Generate node configurations
Navigate to the op-node and generate the configuration for the L3 node:
Step 5: Initialize and start op-geth
Navigate to the op-geth directory and initialize the genesis configuration:
Then, start the op-geth:
Step 6: Add DA-config to op-node
Navigate to op-node folder and add the following to the rollup.json:
Add:
Go to https://explorer.testnet.citrea.xyz/ to check for the correct hash.
Step 7: Run op-node
Go back to the main optimism directory, and build op-node:
Then let's run the node:
Step 8: Run op-batcher
Go back to the main optimism directory, and build the op-batcher:
Then let's run the batcher:
Step 9: Run op-proposer
Go back to optimism main folder, and build the op-proposer:
Then let's run the proposer:
Thatβs it! Enjoy your Bitcoin Appchain on Citrea!
Last updated
Was this helpful?