Operators
Creating your own rollup testnet

Creating your own L2 rollup testnet

Welcome to the complete guide for deploying your own OP Stack L2 rollup testnet. This multi-part tutorial will walk you through each component step-by-step, from initial setup to a fully functioning rollup.

This tutorial requires intermediate-level experience working with EVM chains. You should be comfortable with concepts like smart contracts, private keys, RPC endpoints, gas fees, and command-line operations. Basic familiarity with Docker is also recommended.

What you'll build

By the end of this tutorial, you'll have a complete OP Stack testnet with:

  • L1 Smart Contracts deployed on Sepolia testnet
  • Execution Client (op-geth) processing transactions
  • Consensus Client (op-node) managing rollup consensus
  • Batcher (op-batcher) publishing transaction data to L1
  • Proposer (op-proposer) submitting state root proposals
  • Challenger (op-challenger) monitoring for disputes

Quick setup (Recommended)

If you want to get started quickly, you can use the complete working implementation provided in this repository. This automated setup handles all the configuration and deployment steps for you.

Complete working example

A complete, working implementation is available in the create-l2-rollup-example/ (opens in a new tab) directory. This includes all necessary scripts, Docker Compose configuration, and example environment files.

Automated setup steps

  1. Clone and navigate to the code directory:

    git clone https://github.com/ethereum-optimism/docs.git
    cd docs/create-l2-rollup-example/
  2. Configure your environment:

    cp .example.env .env
    # Edit .env with your L1_RPC_URL, PRIVATE_KEY, and other settings
  3. Run the automated setup:

    make init    # Download op-deployer
    make setup   # Deploy contracts and generate configs
    make up      # Start all services
    make test-l1 # Verify L1 connectivity
    make test-l2 # Verify L2 functionality
  4. Monitor your rollup:

    make logs     # View all service logs
    make status   # Check service health

The automated setup uses the standard OP Stack environment variable conventions (prefixed with OP_*) and handles all the complex configuration automatically.

Manual setup (Step-by-Step)

If you prefer to understand each component in detail or need custom configurations, follow the step-by-step guide below.

Before you start

Software dependencies

DependencyVersionVersion check command
git (opens in a new tab)^2git --version
go (opens in a new tab)^1.21go version
node (opens in a new tab)^20node --version
pnpm (opens in a new tab)^8pnpm --version
foundry (opens in a new tab)^0.2.0forge --version
make (opens in a new tab)^3make --version
jq (opens in a new tab)^1.6jq --version
direnv (opens in a new tab)^2direnv --version
Docker (opens in a new tab)^24docker --version

Notes on specific dependencies

Expand each dependency below for details

node

We recommend using the latest LTS version of Node.js (currently v20).
nvm (opens in a new tab) is a useful tool that can help you manage multiple versions of Node.js on your machine.
You may experience unexpected errors on older versions of Node.js.

foundry

We will use cast to generate wallet addresses in this guide.

direnv

Parts of this tutorial use direnv (opens in a new tab) as a way of loading environment variables from .envrc files into your shell.
This means you won't have to manually export environment variables every time you want to use them.
direnv only ever has access to files that you explicitly allow it to see.

After installing direnv (opens in a new tab), you will need to make sure that direnv is hooked into your shell (opens in a new tab).
Make sure you've followed the guide on the direnv website (opens in a new tab), then close your terminal and reopen it so that the changes take effect (or source your config file if you know how to do that).

πŸ’‘

Make sure that you have correctly hooked direnv into your shell by modifying your shell configuration file (like ~/.bashrc or ~/.zshrc).
If you haven't edited a config file then you probably haven't configured direnv properly (and things might not work later).

Docker

Docker is used extensively in this tutorial for running various OP Stack components.
Make sure you have both Docker and Docker Compose installed and running on your system.
On Linux, you may need to configure Docker to run without sudo (opens in a new tab).

πŸ’‘

If you're using Docker Desktop, ensure it's running before starting the tutorial.
You can verify your installation with:

docker run hello-world

Get access to a sepolia node

Since you're deploying your OP Stack chain to Sepolia, you'll need to have access to a Sepolia node. You can either use a node provider like Alchemy (opens in a new tab) (easier) or run your own Sepolia node (harder).

Required resources

⚠️

Testnet Only: This guide is for testnet deployment only.

Follow in Order: Each step builds on the previous one. Start with spinning up op-deployer and complete them sequentially for the best experience.

Directory structure

To keep your rollup deployment organized, we'll create a dedicated directory structure. All components will be set up within this structure:

rollup/
β”œβ”€β”€ deployer/        # op-deployer files and contracts
β”œβ”€β”€ sequencer/  # op-geth and op-node
β”œβ”€β”€ batcher/    # op-batcher configuration
β”œβ”€β”€ proposer/   # op-proposer setup
└── challenger/ # op-challenger files

Each component's documentation will show you how the directory structure evolves as you add files and configurations.

Throughout this tutorial, all file paths will be relative to this rollup directory structure. Make sure to adjust any commands if you use different directory names.

Manual Tutorial Overview

If you're following the manual setup path, this tutorial is organized into sequential steps that build upon each other:

Spin up op-deployer

Install op-deployer, deploy L1 contracts, and prepare your environment

Spin up sequencer

Set up and run op-geth and op-node (the execution and consensus layers)

Spin up batcher

Configure and start op-batcher for L1 data publishing

Spin up proposer

Set up op-proposer for state root submissions

Spin up challenger

Configure op-challenger for dispute resolution monitoring

Ready to Start?

Now that you understand what you'll be building, let's begin with the first step!

Spin up op-deployer β†’

Need Help?