Provides Rosetta API compatibility for Optimism Bedrock, a low-cost and lightning-fast Ethereum L2 blockchain.
op-rosetta
is an executable client extending the rosetta-geth-sdk which itself extends rosetta-sdk-go.
To learn more about the Rosetta API, you can find more online at rosetta-api.org.
First, clone the repository:
git clone https://github.com/mdehoog/op-rosetta.git
Then, configure your own .env
file by copying the contents of .env.example
to .env
.
cp .env.example .env
The .env
variables will need to be configured.
Run the op-rosetta
client for goerli like so: make run-optimism-goerli
.
As part of the run-optimism-goerli
step inside the makefile, a few parameters are specified before running the bin/op-rosetta
executable:
CHAIN_CONFIG='{ "chainId": 10, "terminalTotalDifficultyPassed": true }' \
MODE=ONLINE \
PORT=8080 \
BLOCKCHAIN=Optimism \
NETWORK=Goerli \
ENABLE_TRACE_CACHE=true \
ENABLE_GETH_TRACER=true \
GETH=${OPTIMISM_GOERLI_NODE} \
GENESIS_BLOCK_HASH=${OPTIMISM_GOERLI_GENESIS_BLOCK_HASH} \
bin/op-rosetta
These parameters are configured as follows:
CHAIN_CONFIG
has the same field values as the genesis config’s. But only thechainId
andterminalTotalDifficultyPassed
values are needed.- Setting
MODE
toONLINE
permits outbound connections. PORT
is set to8080
- the default connection forrosetta-cli
.BLOCKCHAIN
isOptimism
andNETWORK
isGoerli
- We enable geth tracing and caching with
ENABLE_TRACE_CACHE
andENABLE_GETH_TRACER
GETH
points to a running op-geth archive node. This should be set in your.env
file by settingOPTIMISM_GOERLI_NODE
to a node url.GENESIS_BLOCK_HASH
is the block hash of the genesis block. This should be set in your.env
file by settingOPTIMISM_GOERLI_GENESIS_BLOCK_HASH
to the goerli bedrock genesis block hash.
A mainnet client can be run with make run-optimism-mainnet
.
Note Mainnet will only be supported once Optimism mainnet is upgraded to its Bedrock Release.
The run-optimism-mainnet
step inside the makefile specifies a similar set of variables as above:
CHAIN_CONFIG='{ "chainId": 10, "terminalTotalDifficultyPassed": true }' \
MODE=ONLINE \
PORT=8080 \
BLOCKCHAIN=Optimism \
NETWORK=Mainnet \
ENABLE_TRACE_CACHE=true \
ENABLE_GETH_TRACER=true \
GETH=${OPTIMISM_MAINNET_NODE} \
GENESIS_BLOCK_HASH=${OPTIMISM_MAINNET_GENESIS_BLOCK_HASH} \
bin/op-rosetta
These parameters are configured as follows:
CHAIN_CONFIG
has the same field values as the genesis config’s. But only thechainId
andterminalTotalDifficultyPassed
values are needed.- Setting
MODE
toONLINE
permits outbound connections. PORT
is set to8080
- the default connection forrosetta-cli
.BLOCKCHAIN
isOptimism
andNETWORK
isMainnet
- We enable geth tracing and caching with
ENABLE_TRACE_CACHE
andENABLE_GETH_TRACER
GETH
points to a running op-geth archive node. This should be set in your.env
file by settingOPTIMISM_MAINNET_NODE
to a node url.GENESIS_BLOCK_HASH
is the block hash of the genesis block. This should be set in your.env
file by settingOPTIMISM_MAINNET_GENESIS_BLOCK_HASH
to the mainnet bedrock genesis block hash.
NOTE: op-rosetta
must be running on the specified host and port provided in the configuration file. For local testing, this can be done as described in the Running section, which will run an instance on localhost, port 8080.
See configs/README.md for more information.
├── assets
│ └── rosetta.png
├── cmd
│ └── main.go -> The `op-rosetta` executable entrypoint
├── configs
│ ├── optimism/ -> Optimism Mainnet and Goerli config files
│ └── README.md
└── pkg
├── client/ -> Optimism Rosetta API client
├── common/ -> Standalone common functionality
├── config/ -> Configuration options
├── handlers/ -> Rosetta API handlers
├── logging/ -> Logging utilities
└── utils/ -> Package utilities
All files within this repository, including code adapted from rosetta-geth-sdk, is licensed under the terms of the Apache 2.0 License unless explicitly stated otherwise.