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.
Step 1: 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.
1.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.
1.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:
1.3 Set Up the Avail Alt DA Server
This server will handle all of your rollupâs data availability.
-
Get Node Info: Crestal provides the Avail node for you, so you donât need to set it up from scratch. Simply follow this guide to get the node details, which will look like this:
-
Clone the Server Repository:
-
Start the Server: 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 URL of the Avail RPC node provided by Crestal.--avail.seed
: Use your walletâs seed phrase here.--avail.appid=135
: Replace135
with your own App ID.
1.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 2: 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 3: 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 4: 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 5: 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 6: Configuring Crestalâs Avail Node
Configure the environment to connect to Crestalâs Avail DA node. Create a .envrc
file and add these variables:
Activate the environment:
Step 7: Deploying Contracts
7.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.
7.2 Update the Configuration
Open the getting_started.json
file and add this at the bottom:
7.3 Deploy Your Contracts
Run the following command in the packages/contracts-bedrock
directory:
Step 8: Running the Rollup Components
8.1 Run Geth
8.2 Run the OP Node
8.3 Run the OP Batcher
8.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 9: Adding Your Rollup Network to the Wallet
Finally, add your custom rollup to a wallet like MetaMask and start playing with your new network!