Build a Rollup with Avail DA and OP Stack
Learn how to build a rollup with Avail, including setting up the Avail Alt DA server, configuring the OP Stack, and deploying contracts.
Prerequisites
For macOS, the installation commands below use Homebrew. If you donât have Homebrew installed, you can install it by running the following command in your terminal:
For Ubuntu, the installation commands below use apt
to install the required software.
Once Homebrew or apt
is set up, you can use the commands in the table below to install the required software.
Software | Version | macOS (Homebrew) | Ubuntu |
---|---|---|---|
Git | OS default | brew install git | sudo apt install -y git curl make jq |
Go | 1.21 | brew install go@1.21 | wget https://go.dev/dl/go1.21.linux-amd64.tar.gz && tar xvzf go1.21.linux-amd64.tar.gz && sudo cp go/bin/go /usr/bin/go && sudo mv go /usr/lib && echo export GOROOT=/usr/lib/go >> ~/.bashrc |
Node.js | ^20 | brew install node | curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash - && sudo apt-get install -y nodejs npm |
Pnpm | 8.5.6 | npm install -g pnpm | sudo npm install -g pnpm |
Make | OS default | xcode-select --install | sudo apt install -y make |
jq | OS default | brew install jq | sudo apt install -y jq |
direnv | Latest | brew install direnv | sudo apt install -y direnv |
Foundry | ^0.2.0 | curl -L https://foundry.paradigm.xyz | bash | curl -L https://foundry.paradigm.xyz | bash |
Step 1: Get Your Avail Node with Crestal
Crestal provides the Avail node for you, so you donât need to set it up from scratch. This node is essential for your rollup because it guarantees that all transaction data is properly stored and easily accessible. This Data Availability (DA) is critical for rollups to verify and confirm transactions.
Hereâs a short summary of how to get a deployed node using the Crestal Carbon testnet:
- Connect to Crestal: Visit the Crestal Carbon Testnet and connect your EVM-compatible wallet.
- Get Test Tokens: Obtain testnet tokens from the Polygon Amoy or Berachain bArtio faucet.
- Use the AI Design Assistant: Define your infrastructure needs, such as DA services and execution stacks, with Crestalâs AI.
- Submit to the Marketplace: Submit your design to the Crestal Intent-Based Marketplace for solver proposals.
- Deploy Node: Once a proposal is selected, Crestal will handle the deployment, and youâll receive the necessary node parameters for integration.
Please follow this guide for more detailed steps on how to get your own node.
After the node is deployed, the node details will look like the ones bellow. The WSS URL will be needed to start the server on the next step, as it allows your rollup to communicate securely and in real-time with the Data Availability layer provided by Crestalâs Avail node
Step 2: Set Up Your Avail Alt DA Server
Before we even touch the OP Stack, we need to get the Avail Alt DA server up and running. This server is the key connection point to Availâs Data Availability (DA) layer, which Crestal provides for you. Letâs set this up first.
2.1 Create a New Wallet for Avail DA and Get Test Tokens
If you donât have a wallet for Avail DA yet, no worriesâweâll get you started right here.
- Install a Wallet Extension: We recommend Subwallet to manage your Avail account.
- Create a New Wallet: Open the wallet extension and create a new account. Make sure to save that seed phrase somewhere safe.
- Example Avail Address:
5E1qtvznhpcCoPzigNFqS5sqMHxo1VTXmX4YSR9yqCiqWrEg
- Example Avail Address:
- Get Avail Test Tokens: Go to the Avail Faucet and paste your new address to get some test tokens.
- Verify Your Tokens: Head over to the Avail Explorer, make sure your wallet is connected, and confirm youâve received the test tokens.
2.2 Generate Your Own Avail DA App ID
Next, letâs register your app on Avail DA using an App ID. This ID is like your appâs unique identifier when interacting with the DA layer.
- Go to the Chainstate Explorer: Visit Avail explorer, uncheck the âInclude Optionâ toggle, and click the â+â next to the method name to fetch all registered App IDs.
- Register Your Own App ID: Follow the official guide to create an App ID for your app.
- Example App ID:
- owner:
5E1qtvznhpcCoPzigNFqS5sqMHxo1VTXmX4YSR9yqCiqWrEg
- id:
135
- owner:
- Example App ID:
2.3 Set Up the Avail Alt DA Server with Crestalâs node
This server will handle all of your rollupâs data availability. You will need the Avail node provided by Crestal at (step 1)[#step-1-get-your-avail-node-with-crestal]for this.
- Clone the Server Repository:
- Start the Server:
Firstly, make sure you have the WSS URL for your node. You can always find the node details by navigating to the Deploy section on the Crestal Carbon Testnet, select your project, and click on View Details at the bottom-right corner of the page.
Then navigate to the avail-alt-da-server
directory and run the following command:
Hereâs a breakdown of the command:
--addr=localhost --port=8000
: Runs the server locally on port 8000.--avail.rpc
: This is the WSS URL of the Avail node provided by Crestal.--avail.seed
: Use your walletâs seed phrase here.--avail.appid=135
: Replace135
with your own App ID.
2.4 Verify the DA Server is Running
After starting the DA server, you should see logs confirming that itâs connected to the Avail network:
Step 3: Create an Infura Account for the Ethereum Sepolia Node
Now that the DA server is running, youâll need an Infura account to interact with Ethereumâs Sepolia testnet.
- Sign Up for Infura: Go to Infura and sign up for a free account.
- Create a New Project: Select Sepolia as the network.
- Note Project Details: Note down the Project ID and API Keyâyouâll need these to connect your rollup to Sepolia.
Your Sepolia node URL will look like this:
Step 4: Building the Optimism Adapter Source
Now that the DA server is running, letâs build the adapter source for Optimism. Clone the Optimism repo and build the required components.
With these commands, youâll have the OP stack components (node, batcher, proposer) ready to go for your rollup.
Step 5: Building Geth
This will help with syncing your rollup chain.
If youâre using brew to install Go, youâll want to update the GORUN
variable in the Makefile:
This ensures your Go environment is properly set up.
Step 6: Generating and Securing Keys
Generate the keys for your rollup roles: Admin, Proposer, Batcher, and Sequencer.
Example output for the Admin key:
Make sure to save all the keys somewhere safe.
Step 7: Network Configuration and Setup
After building the necessary repositories, the next step is to configure your chain settings. Create a .envrc
file and add these variables:
Activate the environment:
Step 8: Deploying Contracts
8.1 Generate Deployment Config
Head over to the packages/contracts-bedrock
directory and run:
This generates a file called getting_started.json
in the deploy-config
folder.
8.2 Update the Configuration
Open the getting_started.json
file and add this at the bottom:
8.3 Deploy Your Contracts
Run the following command in the packages/contracts-bedrock
directory:
Step 9: Running the Rollup Components
9.1 Run Geth
9.2 Run the OP Node
9.3 Run the OP Batcher
9.4 Run the OP Proposer
Grab the L2OutputOracleProxy
address from your [chain-id]-deploy.json
file, located at packages/contracts-bedrock/deployments
.
Now run the OP Proposer:
Step 10: Adding Your Rollup Network to the Wallet
Finally, add your custom rollup to a wallet like MetaMask and start playing with your new network!