# Running a Development Node


You can check out one of the getting started tutorials (opens new window) for a step-by-step guide to creating and using a development node. You can also find some more detailed information about working with the development node on the Optimism monorepo (opens new window).

# What is this?

A development node is a local installation of Optimism. Having such an installation lets you debug your optimistic application with the performance of a local server before you "graduate" to our testnet prior to a mainnet deployment.

# What does it include?

Hopefully, everything you need to test an optimistic application:

  1. An L1 network available at https://localhost:9545.
  2. An L2 network available at https://localhost:8545.
  3. An account with 10k ETH to spend on testing (the account mnemonic is test test test test test test test test test test test junk).
  4. All the Optimism contracts and servers for cross domain communications, except that the challenge period is a few seconds instead of a week.

# Prerequisites

You'll need to install the following before you can continue:

  1. Docker (opens new window)
  2. Docker compose (opens new window)
  3. Node.js (opens new window), version 12 or later
  4. Classic Yarn (opens new window)

# Creating a node

You can either download the docker images from Docker Hub (opens new window) or build the software from the source code (opens new window).

# Downloading the docker images

If you want to download the images, perform these steps:

  1. Clone the Optimism monorepo (opens new window) and use the develop branch.

    git clone https://github.com/ethereum-optimism/optimism.git -b develop
  2. Download the images from the Docker hub (opens new window). Depending on the hardware and network connection, this process can take up to ten minutes.

    cd optimism/ops
    docker-compose -f docker-compose-nobuild.yml up -t 600 --no-start

    If you want to start the development node as soon as it is downloaded, remove the --no-start argument.

    You might get a timeout at first. If that is the case, just run the docker-compose command again.

# Building from source

If you want to build from the source code, perform these steps:

  1. Clone the Optimism monorepo (opens new window).

    git clone https://github.com/ethereum-optimism/optimism.git
    cd optimism
  2. Install all of the dependencies.

    yarn install
  3. Build the packages.

    yarn build
  4. Build the Docker containers

    cd ops
    export DOCKER_BUILDKIT=1
    docker-compose build && echo "Build complete"
  5. Wait for the "Build complete" message to appear.

# Using the node

# Starting the node

  • To start a node for which you downloaded the images use:
cd optimism/ops
docker-compose -f docker-compose-nobuild.yml up
  • To start a node which you compiled and build yourself, use:
cd optimism/ops
docker-compose up

The startup process may take some time. For the impatient, you can run the following script to know when your node is ready. The script will exit once the system has fully started up.

cd optimism/ops

# Accessing the node

docker-compose up creates both an L1 node and an L2 node. You can interact with both of these nodes at the following ports:

Node Port
L2 (Optimism dev node) 8545
L1 (hardhat (opens new window) dev node) 9545

Click here to see the differences between the L1 Ethereum RPC interface and the Optimism RPC interface

# Getting ETH on your dev node

All of the default hardhat accounts are funded with ETH on both L1 and L2. These accounts are derived from the following mnemonic:

test test test test test test test test test test test junk

You can also generate the complete list of accounts and private keys by running:

npx hardhat node

# Accessing logs

The logs appear on the command-line window used for the docker-compose up command, but they scroll too quickly to be of much use. If you'd like to look at the logs for a specific container, you'll first need to know the name of the container you want to inspect. Run the following command to get the name of all running containers:

docker ps -a --format '{{.Image}}\t\t\t{{.Names}}'

The output includes two columns. The first is the name of the image, and the second the name of the container.

IMAGE                                     NAMES
ethereumoptimism/l2geth                   ops_replica_1
ethereumoptimism/l2geth                   ops_verifier_1
ethereumoptimism/message-relayer          ops_relayer_1
ethereumoptimism/batch-submitter          ops_batch_submitter_1
ethereumoptimism/data-transport-layer     ops_dtl_1
ethereumoptimism/l2geth                   ops_l2geth_1
ethereumoptimism/deployer                 ops_deployer_1
ethereumoptimism/builder                  ops_builder_1
ethereumoptimism/hardhat                  ops_l1_chain_1
ethereumoptimism/integration-tests        ops_integration_tests_1

Next, run docker logs <name of container>. For example, to see the L1 logs, run:

docker logs ops_l1_chain_1

If you'd like to follow these logs as they're being generated, run:

docker logs --follow <name of container>

# Getting contract addresses

The Optimism contracts are already deployed on the development nodes. The contracts on L2 always have the same addresses, so you can get them from the repository (opens new window). But the L1 addresses can vary, and you need to get them from the logs.

For example, use this command to get the addresses for contracts that are used to relay data:

docker logs ops_relayer_1 |& grep 'Connected to OVM_' | tail -4