> For the complete documentation index, see [llms.txt](https://docs.bloxroute.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bloxroute.com/bsc/streams/receipts-streams/traceblocks.md).

# traceBlocks

**`traceBlocks`** is a stream of all new blocks as they are propagated in the BDN, with statediffs and emitted logs for each transaction inside the block, traced on the resultant state from the preceding transaction.

**Service available on Cloud-API only.**

## Stream Endpoint

* Method: `traceBlocks`
* Cloud-API Endpoint: `wss://mev.api.blxrbdn.com/ws`

#### Options

| Key           | Description                            | Values                                                                                                                                                                                                                                                                                                                                   |
| ------------- | -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`include`** | Fields to include in the block stream. | <p><strong><code>hash,header,transactions,future\_validator\_info,withdrawals</code></strong></p><p><em>\[Default: all]</em><br><br><em><strong>future\_validator\_info</strong></em> contains validator addresses for future blocks and indicates whether the validators are connected to the BDN (currently only supported in BSC)</p> |

### **Examples (Websocket)**

#### Cloud-API

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

```bash
wscat -c wss://mev.api.blxrbdn.com/ws --header "Authorization: <YOUR-AUTHORIZATION-HEADER>"
> {"jsonrpc": "2.0", "id": 1, "method": "subscribe", "params": ["traceBlocks", {"include": [], "blockchain_network": "BSC-Mainnet"}]}
< ......
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
var fs = require('fs');
const WebSocket = require('ws');

const ws = new WebSocket(
  'wss://mev.api.blxrbdn.com/ws', 
  
  {
    headers: { 
      "Authorization" : <YOUR-AUTHORIZATION-HEADER> 
    },
    // Add the following line if you work with IP instead of DNS
    // rejectUnauthorized: false,
  }
);

function proceed() {
    ws.send(`{"jsonrpc": "2.0", "id": 1, "method": "subscribe", "params":  ["traceBlocks", {"include": [], "blockchain_network": "BSC-Mainnet"}]}`);

}


function handle(nextNotification) {
    console.log(nextNotification.toString()); // or process it generally
}

ws.on('open', proceed);
ws.on('message', handle);
```

{% endtab %}

{% tab title="Python" %}

```python
# Python version 3.7 or higher required
import asyncio, json, websockets

async def main():
    try:
        # Enterprise users and above
        uri = "wss://mev.api.blxrbdn.com/ws"
        auth_key = "YOUR_AUTHORIZATION_HEADER"
        
        async with websockets.connect(
            uri, 
            header=["Authorization:{}".format(auth_key)],
            # Add the following line if you work with IP instead of DNS
            # sslopt={"cert_reqs": ssl.CERT_NONE}
            ) as websocket:

                subscription_request = json.dumps({
                    "jsonrpc": "2.0",
                    "method": "subscribe",
                    "params": ["traceBlocks", {"include": [], "blockchain_network": "BSC-Mainnet"}],
                    "id": 1,
                })
                

                await websocket.send(subscription_request)
                while True:
                    response = await websocket.recv()
                    print(response)  # or process it generally
    except Exception as e:
        print(f'Connection failed, Reason: {e}')

if __name__ == '__main__':
    asyncio.run(main())
```

{% endtab %}

{% tab title="Golang" %}

```go
package main

import (
	"crypto/tls"
	"fmt"
	"github.com/gorilla/websocket"
	"net/http"
)

func main() {
	dialer := websocket.DefaultDialer
	// Add the following lines if you work with IP instead of DNS
	// tlsConfig := &tls.Config{
	// 	Certificates:       []tls.Certificate{cert},
	// 	InsecureSkipVerify: true,
	// }
	// dialer.TLSClientConfig = tlsConfig


	wsSubscriber, _, err := dialer.Dial("wss://mev.api.blxrbdn.com/ws", http.Header{"Authorization": []string{<YOUR-AUTHORIZATION-HEADER>}})

	if err != nil {
		fmt.Println(err)
		return
	}

	subRequest := `{"id": 1, "method": "subscribe", "params": ["traceBlocks", {"include": [], "blockchain_network": "BSC-Mainnet"}]}`

	err = wsSubscriber.WriteMessage(websocket.TextMessage, []byte(subRequest))
	if err != nil {
		fmt.Println(err)
		return
	}

	for {
		_, nextNotification, err := wsSubscriber.ReadMessage()
		if err != nil {
			fmt.Println(err)
		}
		fmt.Println(string(nextNotification)) // or process it generally
	}
}

```

{% endtab %}
{% endtabs %}

#### Response (Block Event)

{% tabs %}
{% tab title="Block Event" %}

```bash
<<< {
  "jsonrpc": "2.0",
  "id": null,
  "method": "subscribe",
  "params": {
    "subscription": "213883fe-b3e2-4da2-b9ba-196a82df8628",
    "result": {
      "hash": "0x079b7f1b5a68d4301cf97df2f81c406aa598dd508e2d1908974b95ddd61a4156",
      "header": {
        "parentHash": "0xafef6c6bd1049febe85834aa84735f81f2e81efd55d85a1076aae0adceba16de",
        "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
        "miner": "0xea674fdde714fd979de3edf0f56aa9716b898ec8",
        "stateRoot": "0x13f4a37eb7d0ca8ea309a631e51cca86eaa1b9765a2e6a9eb1614ddcf4ea57e4",
        "transactionsRoot": "0x33d0f3c1ce4e3be6346738465cafc727f3500990c881d6fe4821567504badfd5",
        "receiptsRoot": "0xad4fe2b36823a0b57f1c640d115eacc8cc1e64c73e49f89a131f206457afbf9f",
        "logsBloom": "0x3862455e6027e5863992de359e89bd33e91312891441903f715503c922420904c00e77b054483930423b7a0b5aa4433342b5c096fb3a0883a970d882b9ac02104582cab5eb046e62c9ca17acba8268e25c103107216cec48bc432d78b54927991c5147080a5781c028102040a28ab8d016439e6f8a4804b44c15c3fa85873c204ab8938d450f702ec2444f5a83028586683439ff6de3e57be46c295514527dbcc717f08804c1ac022fcccac7c058d447122e109294a38c3b1a2a676c9814c6913200414e638eb046ed244035875a0c2e446132bd450223952a9bbcd694666884a03db1340b8010dfaae464948a9b4ae524ff8a942258445c73ce176bee981b7d",
        "difficulty": "0xc39780fb04af3",
        "number": "0xab05c3",
        "gasLimit": "0xbdfca5",
        "gasUsed": "0xbdb8e3",
        "timestamp": "0x5fa62290",
        "extraData": "0x65746865726d696e652d6575312d36",
        "mixHash": "0x3cd96f6536c1cc745ce9a4f767d65a94b64392bc787e029e7c16339641265b0a",
        "nonce": "0x327b58b8b7216cf5",
        "blobGasUsed": "0xa0000",
        "excessBlobGas": "0x4b40000",
        "parentBeaconBlockRoot": "0x14e886e6...908fe06ba3c"
      },
      "future_validator_info": [
        {
          "block_height": 22460216,
          "wallet_id": "0x295e26495cef6f69dfa69911d9d8e4f3bbadb89b",
          "accessible": true
        },
        {
          "block_height": 22460217,
          "wallet_id": "0x2d4c407bbe49438ed859fe965b140dcf1aab71a9",
          "accessible": false
        }
      ],
      "transactions": [
        {
          "from": "0xea674fdde714fd979de3edf0f56aa9716b898ec8",
          "gas": "0xc350",
          "gasPrice": "0x3b9aca00",
          "hash": "0x587a2db59d1af16aa03521a711c3db5b443e5d05cfc72eccadb89c99380f7da0",
          "input": "0x",
          "nonce": "0x1b8a09b",
          "value": "0x54fbe53cd2d1338",
          "v": "0x25",
          "r": "0x41f3261e25a3e77abd4b0bd4f21cfc2d92ca2d52ff9c663c9a68c6a382115dac",
          "s": "0x4350bb6f770bb3363094774fe36478b20013c705f4041fc1bcd0f9fe520c9a23",
          "to": "0x190aab185dbf089b1c5cf06a4f13421c14fc18fa",
          "logs": [
            {
              "address": "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",
              "topics": [
                "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
                "0x000000000000000000000000802b65b5d9016621e66003aed0b16615093f328b",
                "0x000000000000000000000000824eb9fadfb377394430d2744fa7c42916de3ece"
              ],
              "data": "0x000000000000000000000000000000000000000000000000048c290665a0c030"
            }
          ],
          "stateDiff": {
            "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c": {
              "0x653d9d82daa42bfecda6b9478f1ccfbfadb6a62429ce367eff2f7e5cce182f6c": "0x00000000000000000000000000000000000000000000008419f91387d438f586"
            }
          }
        }
      ],
      "withdrawals": [
        {
          "index": "0x1506516",
          "validatorIndex": "0x18ea9",
          "address": "0x8e609ac80f4324e499a6efd24f221a2caa868224",
          "amount": "0x379ea6b"
        },
        {
          "index": "0x1506517",
          "validatorIndex": "0x18eaa",
          "address": "0x8e609ac80f4324e499a6efd24f221a2caa868224",
          "amount": "0x102d9b3"
        }
      ],
      "uncles": [
        
      ]
    }
  }
}
```

{% endtab %}
{% endtabs %}

###


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.bloxroute.com/bsc/streams/receipts-streams/traceblocks.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
