From 8e72311db50f41d96f978d9f1d5536d0a8fea656 Mon Sep 17 00:00:00 2001 From: William Law Date: Tue, 27 Jan 2026 16:49:50 -0500 Subject: [PATCH 1/3] spike --- docs/base-chain/flashblocks/apps.mdx | 40 ++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/docs/base-chain/flashblocks/apps.mdx b/docs/base-chain/flashblocks/apps.mdx index a96c26d57..ab77c6c5d 100644 --- a/docs/base-chain/flashblocks/apps.mdx +++ b/docs/base-chain/flashblocks/apps.mdx @@ -200,6 +200,46 @@ curl https://sepolia-preconf.base.org -X POST -H "Content-Type: application/json } ``` +#### eth_subscribe Beta + +Subscribe to real-time streams of Flashblocks data. Three subscription types are available: + +- **pendingLogs** - Stream logs from transactions in Flashblocks +- **newFlashblockTransactions** - Stream transaction hashes included in the block +- **newFlashblocks** - Stream the pending block as new Flashblocks arrive + +``` +wscat -c wss://sepolia-preconf.base.org +> {"jsonrpc":"2.0","method":"eth_subscribe","params":["newFlashblocks"],"id":1} +``` + +**Example Response** +``` +{ + "jsonrpc": "2.0", + "id": 1, + "result": "0x..." // subscription ID +} +``` + +#### base_transactionStatus Beta + +Check whether a transaction is present in the mempool: +``` +curl https://sepolia-preconf.base.org -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"base_transactionStatus","params":["0x..."],"id":1}' +``` + +**Example Response** +``` +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + "status": "pending" + } +} +``` + ### Libraries You will need to use a Flashblocks-aware RPC endpoint to use Flashblocks with the following libraries: From c79ed640fb9d1c087d4ca3f7d1602e99b77f2eb4 Mon Sep 17 00:00:00 2001 From: William Law Date: Tue, 27 Jan 2026 17:22:09 -0500 Subject: [PATCH 2/3] fix ws example --- docs/base-chain/flashblocks/apps.mdx | 54 +++++++++++++++++++++------- 1 file changed, 42 insertions(+), 12 deletions(-) diff --git a/docs/base-chain/flashblocks/apps.mdx b/docs/base-chain/flashblocks/apps.mdx index ab77c6c5d..db8047bf2 100644 --- a/docs/base-chain/flashblocks/apps.mdx +++ b/docs/base-chain/flashblocks/apps.mdx @@ -202,24 +202,54 @@ curl https://sepolia-preconf.base.org -X POST -H "Content-Type: application/json #### eth_subscribe Beta -Subscribe to real-time streams of Flashblocks data. Three subscription types are available: +Subscribe to real-time streams of Flashblocks data via WebSocket. Three subscription types are available: - **pendingLogs** - Stream logs from transactions in Flashblocks - **newFlashblockTransactions** - Stream transaction hashes included in the block - **newFlashblocks** - Stream the pending block as new Flashblocks arrive -``` -wscat -c wss://sepolia-preconf.base.org -> {"jsonrpc":"2.0","method":"eth_subscribe","params":["newFlashblocks"],"id":1} -``` +```javascript +import WebSocket from 'ws'; +import { createHash } from 'crypto'; + +const ws = new WebSocket('wss://sepolia.flashblocks.base.org/ws'); + +ws.on('open', () => { + console.log('Connected to Flashblocks WebSocket'); + // Subscribe to new Flashblocks + ws.send(JSON.stringify({ + jsonrpc: "2.0", + method: "eth_subscribe", + params: ["newFlashblockTransactions"], + id: 1 + })); +}); -**Example Response** -``` -{ - "jsonrpc": "2.0", - "id": 1, - "result": "0x..." // subscription ID -} +ws.on('message', (data: WebSocket.Data) => { + try { + if (Buffer.isBuffer(data)) { + if (data.length >= 37) { + const txHash = '0x' + data.slice(5, 37).toString('hex'); + console.log(txHash); + } + } else { + const response = JSON.parse(data.toString()); + if (response.id === 1) { + console.log('✓ Subscribed'); + } + } + } catch (error) { + // Handle error + } +}); + +ws.on('error', (error) => { + console.error('WebSocket error:', error); +}); + +ws.on('close', () => { + console.log('WebSocket connection closed'); +}); ``` #### base_transactionStatus Beta From ea991e1bfd41d1f65c365c982bd9e065142c9910 Mon Sep 17 00:00:00 2001 From: William Law Date: Tue, 27 Jan 2026 17:56:27 -0500 Subject: [PATCH 3/3] add min client version --- docs/base-chain/flashblocks/apps.mdx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/base-chain/flashblocks/apps.mdx b/docs/base-chain/flashblocks/apps.mdx index db8047bf2..2dc406e26 100644 --- a/docs/base-chain/flashblocks/apps.mdx +++ b/docs/base-chain/flashblocks/apps.mdx @@ -204,6 +204,8 @@ curl https://sepolia-preconf.base.org -X POST -H "Content-Type: application/json Subscribe to real-time streams of Flashblocks data via WebSocket. Three subscription types are available: +Requires node-reth minimum client version v0.3.0 + - **pendingLogs** - Stream logs from transactions in Flashblocks - **newFlashblockTransactions** - Stream transaction hashes included in the block - **newFlashblocks** - Stream the pending block as new Flashblocks arrive @@ -255,6 +257,8 @@ ws.on('close', () => { #### base_transactionStatus Beta Check whether a transaction is present in the mempool: + +Requires node-reth minimum client version v0.3.0 ``` curl https://sepolia-preconf.base.org -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"base_transactionStatus","params":["0x..."],"id":1}' ```