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 Availarrow-up-right as the data availability layer.

The following steps are appropriately modified from the Optimism documentationarrow-up-right.

Prerequisites

We recommend opening a separate folder in your filesystem for the rest of this guide.

circle-check

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 herearrow-up-right.

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 herearrow-up-right.

Step 1.3 Create an AppID

Create an AppID on Avail DA and save the AppID value. Follow the steps herearrow-up-right.

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.example to .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:

circle-info

Note: Make sure your state-dump file matches your chain ID. It should be in the format ../packages/contracts-bedrock/state-dump-<L2_CHAIN_ID>-fjord.json.

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:

circle-info

Note: at the top of rollup.json the L1 blockhash may be incorrect with respect to L1 block number. Be sure to check and replace the hash. This is a bug in OP Stack repo.

Go to https://explorer.testnet.citrea.xyz/arrow-up-right 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?