Skip to content

Commit 7a57724

Browse files
committed
Add OP Scan block explorer to Optimism Docs
1 parent cd62e08 commit 7a57724

File tree

2 files changed

+166
-0
lines changed

2 files changed

+166
-0
lines changed

pages/builders/chain-operators/tools/_meta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
"op-conductor": "op-conductor",
66
"op-deployer": "op-deployer",
77
"op-txproxy": "op-txproxy",
8+
"op-scan": "OP Scan Block Explorer",
89
"proxyd": "proxyd"
910
}
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
---
2+
title: op-scan
3+
lang: en-US
4+
description: Learn how to launch OP Scan, a block explorer designed for your OP Stack chain.
5+
---
6+
7+
import { Callout } from "nextra/components";
8+
9+
# 🔎 OP Scan
10+
11+
OP Scan is a transaction explorer tailored specifically for the [OP Stack](https://docs.optimism.io/builders/chain-operators/tutorials/create-l2-rollup) and the [Superchain vision](https://www.youtube.com/watch?v=O6vYNgrQ1LE). It's focused on being lightweight so that anyone can run it locally next to an OP Stack devnet or any other compatible OP Stack based rollup.
12+
13+
<Callout>
14+
Check out the [OP Scan README](https://github.com/walnuthq/op-scan) for
15+
up-to-date information on how to launch OP Scan.
16+
</Callout>
17+
18+
![screenshot](https://raw.githubusercontent.com/walnuthq/op-scan/main/screenshot.png)
19+
20+
# ⚙️ Installation
21+
22+
### Getting Started Video
23+
24+
[Here's a video walkthrough](https://www.loom.com/share/3b79f0b25e44443eb16d296aba021764) on how to launch the explorer locally configured for OP Sepolia testnet.
25+
26+
### Required Dependencies
27+
28+
The app requires the following dependencies:
29+
30+
```
31+
NodeJS >= 22
32+
pnpm >= 9
33+
```
34+
35+
### Explorer Configuration
36+
37+
Clone this repository:
38+
39+
```sh
40+
git clone [email protected]:walnuthq/op-scan
41+
```
42+
43+
Install the dependencies:
44+
45+
```sh
46+
pnpm install
47+
```
48+
49+
You will need to copy `.env.local.example` into `.env.local` at the root of your repository and populate it with your own values.
50+
51+
In particular you will need to provide configuration for both L1 and L2 chains:
52+
53+
```
54+
NEXT_PUBLIC_L1_CHAIN_ID="11155111"
55+
NEXT_PUBLIC_L1_NAME="Sepolia"
56+
NEXT_PUBLIC_L1_RPC_URL="https://ethereum-sepolia-rpc.publicnode.com"
57+
NEXT_PUBLIC_L2_CHAIN_ID="11155420"
58+
NEXT_PUBLIC_L2_NAME="OP Sepolia"
59+
NEXT_PUBLIC_L2_RPC_URL="https://optimism-sepolia-rpc.publicnode.com"
60+
```
61+
62+
You can get free node rpcs url by signing up to services such as [Alchemy](https://www.alchemy.com/), [Infura](https://www.infura.io/) or [QuickNode](https://www.quicknode.com/).
63+
64+
You will also need to provide your L1 contracts addresses when using a devnet:
65+
66+
```
67+
NEXT_PUBLIC_OPTIMISM_PORTAL_ADDRESS="..."
68+
NEXT_PUBLIC_L1_CROSS_DOMAIN_MESSENGER_ADDRESS="..."
69+
```
70+
71+
You will find theses addresses in your rollup deployment artifacts in `contracts-bedrock/deployments/your-deployment/L1Contract.json`.
72+
Note that you always need to provide the proxy address, not the underlying contract.
73+
74+
If you don't want to run the explorer with your local chain setup, you will find all the necessary environment variables in `.env.local.example` to configure the explorer with OP Sepolia or OP Mainnet.
75+
76+
If you want to be able to use the Write Contract feature on verified contracts, you will also need to provide a [Reown](https://docs.reown.com/) project ID.
77+
78+
```
79+
NEXT_PUBLIC_REOWN_PROJECT_ID="REOWN_PROJECT_ID"
80+
```
81+
82+
### Indexer Configuration
83+
84+
To run the indexer, you first need to setup your `DATABASE_URL` in `.env.local` (we use SQLite by default but you can switch to PostgreSQL by changing the Prisma provider in `prisma/schema.prisma`) as well as websocket connections to your L1/L2 chains:
85+
86+
```
87+
DATABASE_URL="file:dev.db"
88+
L1_RPC_WS="wss://ethereum-sepolia-rpc.publicnode.com"
89+
L2_RPC_WS="wss://optimism-sepolia-rpc.publicnode.com"
90+
```
91+
92+
Then you can sync your local database with the Prisma schema:
93+
94+
```sh
95+
pnpm prisma:db:push
96+
```
97+
98+
Now you will be able to start indexing the blockchain by running the `op-indexer` command:
99+
100+
```sh
101+
pnpm op-indexer
102+
```
103+
104+
You should start seeing blocks getting indexed in your terminal and you can explore the state of your local database using Prisma studio:
105+
106+
```sh
107+
pnpm prisma:studio
108+
```
109+
110+
If you need to change the Prisma schema at some point, make sure to regenerate the Prisma client and push to your local database:
111+
112+
```sh
113+
pnpm prisma:generate
114+
pnpm prisma:db:push
115+
```
116+
117+
Indexing a blockchain is putting a heavy load on the RPC as you need to perform a large number of JSON-RPC requests to fully index a block (along with transactions and logs).
118+
When indexing non-local chains you will probably encounter 429 errors related to rate-limiting, you may provide up to 5 fallback RPC URLs in case this happens:
119+
120+
```
121+
NEXT_PUBLIC_L1_FALLBACK1_RPC_URL="https://rpc.ankr.com/eth_sepolia"
122+
NEXT_PUBLIC_L2_FALLBACK1_RPC_URL="https://rpc.ankr.com/optimism_sepolia"
123+
NEXT_PUBLIC_L1_FALLBACK2_RPC_URL="https://endpoints.omniatech.io/v1/eth/sepolia/public"
124+
NEXT_PUBLIC_L2_FALLBACK2_RPC_URL="https://endpoints.omniatech.io/v1/op/sepolia/public"
125+
NEXT_PUBLIC_L1_FALLBACK3_RPC_URL="https://sepolia.drpc.org"
126+
NEXT_PUBLIC_L2_FALLBACK3_RPC_URL="https://optimism-sepolia.drpc.org"
127+
NEXT_PUBLIC_L1_FALLBACK4_RPC_URL="https://eth-sepolia.g.alchemy.com/v2/FALLBACK4_API_KEY"
128+
NEXT_PUBLIC_L2_FALLBACK4_RPC_URL="https://opt-sepolia.g.alchemy.com/v2/FALLBACK4_API_KEY"
129+
NEXT_PUBLIC_L1_FALLBACK5_RPC_URL="https://sepolia.infura.io/v3/FALLBACK5_API_KEY"
130+
NEXT_PUBLIC_L2_FALLBACK5_RPC_URL="https://optimism-sepolia.infura.io/v3/FALLBACK5_API_KEY"
131+
```
132+
133+
You can pass several parameters to the indexer to control the indexing range and execution:
134+
135+
- `--l2-from-block` (short `-f`, defaults to latest block) start indexing from this L2 block.
136+
- `--l2-index-block` (short `-b`) index this particular L2 block number.
137+
- `--l1-from-block` (defaults to latest block) start indexing from this L1 block.
138+
- `--l1-index-block` index this particular L1 block number.
139+
- `--index-delay` (short `-d`, defaults to 1000) delay in ms between indexing 2 blocks to avoid overloading the RPC.
140+
141+
Example of running the indexer:
142+
143+
```sh
144+
pnpm op-indexer -f 123416717 --l1-index-block 20426733 --l1-index-block 20426726 -d 500
145+
```
146+
147+
### Running the Explorer
148+
149+
When you're done configuring your environment variables you can build the app:
150+
151+
```sh
152+
pnpm build
153+
```
154+
155+
Make sure your local chain is started and the indexer is running, then launch the explorer to see it live at `http://localhost:3000`
156+
157+
```sh
158+
pnpm start
159+
```
160+
161+
Alternatively you can launch the explorer in dev mode if you want to customize it:
162+
163+
```sh
164+
pnpm dev
165+
```

0 commit comments

Comments
 (0)