Skip to content

Cyberking99/optimistic-rollup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

Creating an OP Rollup Using OP Stack: Comprehensive Guide

1. Software Dependencies

Here are the required software dependencies:

Dependency Version Version Check Command
git ^2 git --version
go ^1.21 go version
node ^20 node --version
pnpm ^8 pnpm --version
foundry ^0.2.0 forge --version
make ^3 make --version
jq ^1.6 jq --version
direnv ^2 direnv --version

2. Build the Optimism Monorepo

  1. Clone the repo:

    git clone https://github.com/ethereum-optimism/optimism.git
    cd optimism
  2. Checkout to "tutorials/chain" branch:

    git checkout tutorials/chain
  3. Check software dependencies:

    ./packages/contracts-bedrock/scripts/getting-started/versions.sh
  4. Install dependencies:

    pnpm install
  5. Build packages:

    make op-node op-batcher op-proposer
    pnpm build

    Note: If you encounter an error related to runtime.stopTheWorld, change your Go version to 1.21.6.

3. Build op-geth

  1. Clone the repo:

    git clone https://github.com/ethereum-optimism/op-geth.git
    cd op-geth
  2. Build op-geth:

    make geth

4. Environment Variables

Open the .envrc file and fill out these variables:

  • L1_RPC_URL: URL for your L1 node (Sepolia node)
  • L1_RPC_KIND: Kind of L1 RPC (options: alchemy, quicknode, infura, parity, nethermind, debug_geth, erigon, basic, any)

5. Generate Addresses

You'll need four addresses and their private keys:

  1. Admin address (can upgrade contracts)
  2. Batcher address (publishes Sequencer transaction data to L1)
  3. Proposer address (publishes L2 transaction results to L1)
  4. Sequencer address (signs blocks on the p2p network)

Generate addresses:

cd optimism
./packages/contracts-bedrock/scripts/getting-started/wallets.sh

Warning: Do not use wallets.sh for production deployments. Use hardware security modules and hardware wallets instead.

Copy the generated addresses to your .envrc file.

Fund the generated addresses:

  • Admin: 0.5 Sepolia ETH
  • Batcher: 0.1 Sepolia ETH
  • Proposer: 0.2 Sepolia ETH

6. Load Environment Variables

  1. Navigate to the optimism monorepo:

    cd optimism
  2. Allow direnv:

    direnv allow

Troubleshooting direnv:

  • Run eval "$(direnv hook bash)"
  • Uninstall and reinstall direnv
  • Build direnv from source
  • Re-execute .envrc file with source .envrc

7. Configure Network

  1. Navigate to the optimism monorepo:

    cd optimism
    cd packages/contracts-bedrock
  2. Install Foundry dependencies:

    forge install
  3. Generate configuration file:

    ./scripts/getting-started/config.sh

8. Deploy L1 Contracts

  1. Deploy using op-deployer:

    forge script scripts/deploy/Deploy.s.sol:Deploy --private-key $GS_ADMIN_PRIVATE_KEY --broadcast --rpc-url $L1_RPC_URL --slow
  2. Install op-deployer:

    cd ~
    git clone https://github.com/ethereum-optimism/optimism.git op-deployer-source
    cd op-deployer-source/op-deployer
    go build -o ~/op-deployer/bin/op-deployer ./cmd/op-deployer
    chmod +x ~/op-deployer/bin/op-deployer
  3. Initialize and configure intent.toml:

    cd ~/op-deployer
    ./bin/op-deployer init --l1-chain-id <L1_CHAIN_ID> --l2-chain-ids <L2_CHAIN_ID> --workdir .deployer
  4. Deploy L1 contracts:

    ./bin/op-deployer apply --workdir .deployer --l1-rpc-url <RPC_URL_FOR_L1> --private-key <DEPLOYER_PRIVATE_KEY_HEX>
  5. Generate L2 genesis and rollup files:

    ./bin/op-deployer inspect genesis --workdir .deployer <L2_CHAIN_ID> > .deployer/genesis.json
    ./bin/op-deployer inspect rollup --workdir .deployer <L2_CHAIN_ID> > .deployer/rollup.json

9. Initialize op-geth

  1. Navigate to op-geth:

    cd optimism/op-geth
  2. Create data directory and build:

    mkdir datadir
    make geth
    cp ~/op-deployer/.deployer/genesis.json ./
    build/bin/geth init --state.scheme=hash --datadir=datadir genesis.json
  3. Start op-geth (command provided in original guide)

10. Initialize op-node

  1. Install just:

    sudo snap install just --classic
  2. Navigate to op-node and build:

    cd ~/op-deployer/op-node
    just op-node
    cp ~/op-deployer/.deployer/rollup.json ./
  3. Start op-node (command provided in original guide)

11. Initialize op-batcher

  1. Navigate to op-batcher:

    cd ~/op-deployer/op-batcher
  2. Build and start op-batcher (command provided in original guide)

12. Initialize op-proposer

  1. Navigate to op-proposer:

    cd ~/op-deployer/op-proposer
  2. Build and start op-proposer (command provided in original guide)

13. Connect Wallet

14. Get ETH on Your Chain

  1. Navigate to contracts-bedrock:

    cd ~/op-deployer/packages/contracts-bedrock
  2. Get L1StandardBridgeProxy address:

    cat deployments/getting-started/.deploy | jq -r .L1StandardBridgeProxy
  3. Send Sepolia ETH to the L1StandardBridgeProxy contract address

15. Interact with Your Rollup

You can now interact with your Rollup like any other EVM chain. Send transactions, deploy contracts, and explore!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published