GetParsedBdnFlashBlockStream
Name: GetParsedBdnFlashBlockStream
The GetParsedBdnFlashBlockStream
stream provides low-latency access to newly produced Flashblocks on the Base network, parsed into protobuf format for immediate use.
Flashblocks are pre-confirmation blocks available before they are finalized on-chain and may differ from the final canonical chain.
This is real-time WS/gRPC, parsed Flashblocks data stream.
Example: WebSocket using CLI
wscat -H "Authorization: <AUTH_HEADER>" \
-c wss://base.blxrbdn.com:5005/ws \
--wait 1000 \
--execute '{"jsonrpc": "2.0", "id": 1, "method": "subscribe", "params": [ "GetParsedBdnFlashBlockStream", {} ]}'
Example: Test with grpcurl
grpcurl -H "Authorization: <AUTH_HEADER>" \
-H "Content-Type: application/grpc" \
-d '{}' \
base.blxrbdn.com:443 \
streamerapi.Api/GetParsedBdnFlashBlockStream
Example: Golang
package main
import (
"encoding/json"
"net/http"
"net/url"
streamerapi "github.com/bloXroute-Labs/base-streamer-proto/streamer_api"
"github.com/gorilla/websocket"
"github.com/rs/zerolog/log"
"google.golang.org/protobuf/encoding/protojson"
)
const (
BxAuthHeader = "PUT_YOUR_AUTH_HEADER"
)
type Params struct {
Subscription string `json:"subscription"`
Result json.RawMessage `json:"result"`
}
type Response struct {
JsonRPC string `json:"jsonrpc"`
Method string `json:"method"`
Params Params `json:"params"`
}
func main() {
u, err := url.Parse("wss://base.blxrbdn.com:5005/ws")
if err != nil {
log.Fatal().Err(err).Msg("Invalid WebSocket URL: ")
}
log.Info().Str("url", u.String()).Msg("Connecting...")
conn, _, err := websocket.DefaultDialer.Dial(u.String(), http.Header{
"Authorization": []string{BxAuthHeader},
})
if err != nil {
log.Fatal().Err(err).Msg("WebSocket connection failed: ")
}
defer conn.Close()
message := []byte(`{"jsonrpc": "2.0", "id": 1, "method": "subscribe", "params": [ "GetParsedBdnFlashBlockStream", {} ]}`)
err = conn.WriteMessage(websocket.TextMessage, message)
if err != nil {
log.Fatal().Err(err).Msg("Error sending message: ")
}
log.Info().Msg("Connected! Listening for parsed bdn flashblocks...")
for {
msgType, msg, err := conn.ReadMessage()
if err != nil {
log.Error().Err(err).Msg("Read error: ")
continue
}
if msgType != websocket.TextMessage {
log.Error().Err(err).Int("msgType", msgType).Msg("Skipping non-text message: ")
continue
}
var response *Response
err = json.Unmarshal(msg, &response)
if err != nil {
log.Error().Err(err).Msg("Failed to unmarshal response: ")
continue
}
if response.Params.Result == nil { // Expected for the first update
log.Warn().Msg("parsedBdnFlashBlock is nil")
continue
}
var parsedBdnFlashBlock streamerapi.GetParsedBdnFlashBlockStreamResponse
err = protojson.Unmarshal(response.Params.Result, &parsedBdnFlashBlock)
if err != nil {
log.Error().Err(err).Msg("Failed to protojson unmarshal parsed bdn flashblock: ")
continue
}
log.Info().Uint64("blockNumber", parsedBdnFlashBlock.Metadata.BlockNumber).Uint64("index", parsedBdnFlashBlock.Index).Msg("parsedBdnFlashBlock")
}
}
Response (Flashblock Event)
Index 0 (with Base): Shows the Flashblock plus chain-level context (
base
).Index 1–10 (without Base): Shows Flashblocks without repeating that extra context.
<<< {
"jsonrpc": "2.0",
"method": "subscribe",
"params": {
"subscription": "7e84d5e2-570b-4750-88c4-fe934ad93531",
"result": {
"payloadId": "0x039e03386af93ec4",
"index": "0",
"base": {
"parentBeaconBlockRoot": "0x3f2b3d2be05b1aa421062640a52a8fb564c310a6608ee77028b54a4e534a44fd",
"parentHash": "0xa373c39558c65f2f276de7c5ca24b92b42b86853d05e9cb4bacc3d28d9c3b5ac",
"feeRecipient": "0x4200000000000000000000000000000000000011",
"prevRandao": "0xe6e6e07efed22009d57c725011d98d65ae24d568620db7342fa8ae7c3426a8f5",
"blockNumber": "0x20ba0f2",
"gasLimit": "0x8f0d180",
"timestamp": "0x68a19ec7",
"extraData": "0x000000003200000003",
"baseFeePerGas": "0x5b777"
},
"diff": {
"stateRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
"receiptsRoot": "0x4a27677b9a161f080a4bdce3a56e6dc7ead5ab900ec62f3c7151a519a45cf6be",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"gasUsed": "0xb44c",
"blockHash": "0x5a70134941f5e08c2b6e122042fefc399606f2e9f7911caed6881c06b3e04792",
"transactions": [
"0x7ef90104a065b3ade1eb334185562510dff0f376f8d8fdaece233e6e3ff8475ee52fbf1fb094deaddeaddeaddeaddeaddeaddeaddeaddead00019442000000000000000000000000000000000000158080830f424080b8b0098999be000008dd00101c1200000000000000050000000068a19e0b0000000001616411000000000000000000000000000000000000000000000000000000000fa68f0900000000000000000000000000000000000000000000000000000000000000010c6071353e4919d87355e022911ddea355fef3f16f0e21e112eade6a58d83d980000000000000000000000005050f69a9786f081509234f1a7f4684b5e5b76c9000000000000000000000000"
],
"withdrawals": [],
"withdrawalsRoot": "0x871f79faec942df96cd90e26b473cb2afca8aee4858d5e2d3fae0c3a64e9ce62"
},
"metadata": {
"blockNumber": "34316530",
"newAccountBalances": {
"0x0000f90827f1c53a10cb7a02335b175320002935": "0x0",
"0x000f3df6d732807ef1319fb7b8bb8522d0beac02": "0x0",
"0x4200000000000000000000000000000000000015": "0x0",
"0xdeaddeaddeaddeaddeaddeaddeaddeaddead0001": "0x69076b18a41d8"
},
"receipts": {
"0x9cfb253a30c498111c6485638b279483c8e61419ee78be3251195c4f88055a02": {
"Deposit": {
"cumulativeGasUsed": "0xb44c",
"logs": [],
"status": "0x1",
"depositNonce": "0x20ba0f4",
"depositReceiptVersion": "0x1"
},
"Eip1559": null,
"Legacy": null
}
}
}
}
}
}
Last updated