# Parsed Flashblocks

`GetParsedBdnFlashBlockStream` feed 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.

**Service available via Cloud API only.**

## Stream Endpoint

* Method: `GetParsedBdnFlashBlockStream`
* Endpoint: `wss://base.blxrbdn.com:5005/ws`

### Examples

**Request**

{% tabs %}
{% tab title="WebSocket" %}

```shellscript
wscat -H "Authorization: <AUTH_HEADER>" \
  -c wss://base.blxrbdn.com:5005/ws \
  --wait 1000 \
  --execute '{"jsonrpc": "2.0", "id": 1, "method": "subscribe", "params": [  "GetParsedBdnFlashBlockStream", {} ]}'
```

{% endtab %}

{% tab title="gRPC" %}

```shellscript
grpcurl -H "Authorization: <AUTH_HEADER>" \
  -H "Content-Type: application/grpc" \
  -d '{}' \
  base.blxrbdn.com:443 \
  streamerapi.Api/GetParsedBdnFlashBlockStream
```

{% endtab %}

{% tab title="Golang" %}

```go
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")
	}
}
```

{% endtab %}
{% endtabs %}

### 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.

{% tabs %}
{% tab title="Index 0 (with Base)" %}

```json
{
  "jsonrpc": "2.0",
  "method": "subscribe",
  "params": {
    "subscription": "37cf3ac8-0c42-4de3-a846-93a57ac94192",
    "result": {
      "payloadId": "0x03272df0619d2be6",
      "index": "0",
      "base": {
        "parentBeaconBlockRoot": "0x18e999429d02c29d269f6bbb0582c44d89b3a7780566326d7f751b2b80cac47d",
        "parentHash": "0xca8312d76b76b1a7c8991726f58c24295753012992bb0441bf7851bd5b37963a",
        "feeRecipient": "0x4200000000000000000000000000000000000011",
        "prevRandao": "0x40f3b694983ecb78f706b5a3a7c8b3a44131751ee1b83d5c78109640ef1cf29d",
        "blockNumber": "0x292e37e",
        "gasLimit": "0x165a0bc0",
        "timestamp": "0x69b023df",
        "extraData": "0x010000007d0000000600000000004c4b40",
        "baseFeePerGas": "0x1a9ec2e"
      },
      "diff": {
        "stateRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "receiptsRoot": "0x9ab33608eaedfbd6777eeaac90ccef8e418fa17186cc3c4ccd007108c830a73b",
        "logsBloom": "0x00000000...",
        "gasUsed": "0xb48a",
        "blockHash": "0x0196aa157b9bd34cf62267190902e82a53a049688094b81309b94bbe01cb6f5a",
        "transactions": [
          "0x7ef90106a0f4..."
        ],
        "withdrawals": [],
        "withdrawalsRoot": "0x59b8ad53c839a066fe3def07c96160ed622eadb469c61bf7de0e5d9938f406ad",
        "blobGasUsed": "0x0"
      },
      "metadata": {
        "blockNumber": "43180926"
      }
    }
  }
}
```

{% endtab %}

{% tab title="Index 1-10 (without Base)" %}

```json
{
  "jsonrpc": "2.0",
  "method": "subscribe",
  "params": {
    "subscription": "99908ef9-866d-46b4-8879-845b21ce7e40",
    "result": {
      "payloadId": "0x032bd028914eb14a",
      "index": "1",
      "base": null,
      "diff": {
        "stateRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "receiptsRoot": "0x7f7709a14a4df083ec46ee667b715056a3865dc341f12a83a0805192b8498a73",
        "logsBloom": "0x40010012482320000...",
        "gasUsed": "0x7826a8",
        "blockHash": "0x6585a097d68710d5b3bc96ad7d89cbd8b06ce7805350fb1f55eb0c670f219d0c",
        "transactions": [
          "0x02f901f98221058305...",
          "0x02f901048221058306..."
        ],
        "withdrawals": [],
        "withdrawalsRoot": "0x59b8ad53c839a066fe3def07c96160ed622eadb469c61bf7de0e5d9938f406ad",
        "blobGasUsed": "0x11ddf8"
      },
      "metadata": {
        "blockNumber": "43181485"
      }
    }
  }
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.bloxroute.com/base/streams/parsed-flashblocks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
