bdnBlocks
Available on Go-Gateway and Cloud API
Name: bdnBlocks
bdnBlocks is a stream of all new blocks as they are propagated in the BDN. The blocks published in the bdnBlocks stream may include blocks that will not be accepted on chain. This stream offers significant performance speed over the newBlocks stream (from the Gateway or the node).

Options

Key
Description
Values
include
Fields to include in the block stream.
hash,header,transactions,uncles
[Default: all]

Examples (Cloud-API)

wscat
Python
Node.js
Golang
1
## ETH Example
2
wscat -c wss://virginia.eth.blxrbdn.com/ws --header "Authorization: <YOUR-AUTHORIZATION-HEADER>"
3
> {"jsonrpc": "2.0", "id": 1, "method": "subscribe", "params": ["bdnBlocks", {"include": ["hash"]}]}
4
< ......
5
​
6
​
7
## BSC Example
8
wscat -c wss://virginia.bsc.blxrbdn.com/ws --header "Authorization: <YOUR-AUTHORIZATION-HEADER>"
9
> {"jsonrpc": "2.0", "id": 1, "method": "subscribe", "params": ["bdnBlocks", {"include": ["hash"], "blockchain_network": "BSC-Mainnet"}]}
10
< ......
11
​
12
​
13
## Polygon Example
14
wscat -c wss://virginia.polygon.blxrbdn.com/ws --header "Authorization: <YOUR-AUTHORIZATION-HEADER>"
15
> {"jsonrpc": "2.0", "id": 1, "method": "subscribe", "params": ["bdnBlocks", {"include": ["hash"], "blockchain_network": "BSC-Mainnet"}]}
16
< ......
17
​
Copied!
1
from bxcommon.rpc.provider.ws_provider import WsProvider
2
​
3
# Enterprise users can follow line 4-9 to
4
async with WsProvider(
5
uri="wss://virginia.eth.blxrbdn.com/ws",
6
headers={"Authorization": <YOUR-AUTHORIZATION-HEADER>},
7
# Add the following line if you work with IP instead of DNS
8
# skip_ssl_cert_verify=True
9
) as ws:
10
​
11
# Non Enterprise users should follow line 12-17
12
# async with WsProvider(
13
# uri="wss://api.blxrbdn.com/ws",
14
# headers={"Authorization": <YOUR-AUTHORIZATION-HEADER>}
15
# Add the following line if you work with IP instead of DNS
16
# skip_ssl_cert_verify=True
17
# ) as ws:
18
​
19
# ETH Example
20
subscription_id = await ws.subscribe("bdnBlocks", {"include": ["hash"]})
21
​
22
# BSC Example (only available at endpoint wss://<region>.bsc.blxrbdn.com/ws)
23
# subscription_id = await ws.subscribe("bdnBlocks", {"include": ["hash"], "blockchain_network": "BSC-Mainnet"})
24
​
25
# Polygon Example (only available at endpoint wss://<region>.polygon.blxrbdn.com/ws)
26
# subscription_id = await ws.subscribe("bdnBlocks", {"include": ["hash"], "blockchain_network": "Polygon-Mainnet"})
27
​
28
while True:
29
next_notification = await ws.get_next_subscription_notification_by_id(subscription_id)
30
print(next_notification) # or process it generally
31
await ws.unsubscribe(subscription_id)
Copied!
1
var fs = require('fs');
2
const WebSocket = require('ws');
3
​
4
// Enterprise users can follow line 5-16
5
const ws = new WebSocket(
6
'wss://virginia.eth.blxrbdn.com/ws', // for ETH
7
// use 'wss://virginia.bsc.blxrbdn.com/ws', //for BSC
8
// use 'wss://virginia.polygon.blxrbdn.com/ws', // for Polygon
9
{
10
headers: {
11
"Authorization" : <YOUR-AUTHORIZATION-HEADER>
12
},
13
// Add the following line if you work with IP instead of DNS
14
// rejectUnauthorized: false,
15
}
16
);
17
​
18
// Non Enterprise users should follow line 19-27
19
// const ws = new WebSocket(
20
// "wss://api.blxrbdn.com/ws",
21
// {
22
// headers: {
23
// "Authorization" : <YOUR-AUTHORIZATION-HEADER>
24
// },
25
// rejectUnauthorized: false,
26
// }
27
// );
28
​
29
function proceed() {
30
// ETH Example
31
ws.send(`{"jsonrpc": "2.0", "id": 1, "method": "subscribe", "params": ["bdnBlocks", {"include": ["tx_hash"]}]}`);
32
​
33
// BSC Example (only available at endpoint wss://<region>.bsc.blxrbdn.com/ws)
34
// ws.send(`{"jsonrpc": "2.0", "id": 1, "method": "subscribe", "params": ["bdnBlocks", {"include": ["hash"], "blockchain_network": "BSC-Mainnet"}]}`);
35
​
36
// Polygon Example (only available at endpoint wss://<region>.polygon.blxrbdn.com/ws)
37
// ws.send(`{"jsonrpc": "2.0", "id": 1, "method": "subscribe", "params": ["bdnBlocks", {"include": ["hash"], "blockchain_network": "Polygon-Mainnet"}]}`);
38
}
39
​
40
​
41
function handle(nextNotification) {
42
console.log(nextNotification.toString()); // or process it generally
43
}
44
​
45
ws.on('open', proceed);
46
ws.on('message', handle);
Copied!
1
package main
2
​
3
import (
4
"crypto/tls"
5
"fmt"
6
"github.com/gorilla/websocket"
7
"net/http"
8
)
9
​
10
func main() {
11
dialer := websocket.DefaultDialer
12
// Add the following lines if you work with IP instead of DNS
13
// tlsConfig := &tls.Config{
14
// Certificates: []tls.Certificate{cert},
15
// InsecureSkipVerify: true,
16
// }
17
// dialer.TLSClientConfig = tlsConfig
18
​
19
// Enterprise users can follow line 20
20
wsSubscriber, _, err := dialer.Dial("wss://virginia.eth.blxrbdn.com/ws", http.Header{"Authorization": []string{<YOUR-AUTHORIZATION-HEADER>}})
21
​
22
// Non Enterprise users can follow line 23
23
// wsSubscriber, _, err := dialer.Dial("wss://api.blxrbdn.com/ws", http.Header{"Authorization": []string{<YOUR-AUTHORIZATION-HEADER>}})
24
​
25
if err != nil {
26
fmt.Println(err)
27
return
28
}
29
​
30
// ETH Example
31
subRequest := `{"id": 1, "method": "subscribe", "params": ["bdnBlocks", {"include": ["hash"]}]}`
32
​
33
// BSC Example (only available at endpoint wss://<region>.bsc.feed.blxrbdn.com:28333)
34
// subRequest := `{"id": 1, "method": "subscribe", "params": ["bdnBlocks", {"include": ["hash"], "blockchain_network": "BSC-Mainnet"}]}`
35
​
36
// Polygon Example (only available at endpoint wss://<region>.polygon.blxrbdn.com:28333)
37
// subRequest := `{"id": 1, "method": "subscribe", "params": ["bdnBlocks", {"include": ["hash"], "blockchain_network": "Polygon-Mainnet"}]}`
38
​
39
err = wsSubscriber.WriteMessage(websocket.TextMessage, []byte(subRequest))
40
if err != nil {
41
fmt.Println(err)
42
return
43
}
44
​
45
for {
46
_, nextNotification, err := wsSubscriber.ReadMessage()
47
if err != nil {
48
fmt.Println(err)
49
}
50
fmt.Println(string(nextNotification)) // or process it generally
51
}
52
}
53
​
Copied!

Response (Block Event)

Block Event
1
<<< {
2
"method": "subscribe",
3
"params": {
4
"subscription": "6ea43ccf-3810-11ec-ad71-0242ac110002",
5
"result": {
6
"hash": "0x95774a847277f19f85742740577812b33be5e8261b13ae0a93828b44401aac80",
7
"header": {
8
"parentHash": "0xf254c84238d1e5c9aca356a7ad01a7dc75c7012c8cb06a43510bdc486027374c",
9
"sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
10
"miner": "0x1ad91ee08f21be3de0ba2ba6918e714da6b45836",
11
"stateRoot": "0xa80ba46395c5cd93a2122296207ed5433a6f0bafdf31a9db43d641a7bc764e55",
12
"transactionsRoot": "0x7588844493391e8503a966f4720d85f83a3e672e314a122db2bb6769b214c90b",
13
"receiptsRoot": "0x8a6aaba9d857189db685a1bb9d179f1cdca9b1c06bd77ff851d31e90734c70bf",
14
"logsBloom": "0xd0fa0757dcfb97f75b80a4f4ffc24bdef632117a9ebcbabb65abf679d77f5bbf96cdc19a58f142755d85db83ef7c13f61f6784706b41fbc9fe56fb2ab7ecedcfc9eeedd34149fd7f2ade66cf7df4f6f5928ba98cafde24ffa4e37fdfe0cc7dbf1fb5e43b42687836fc7c1e958f11edf47f77b9f2b0357e707a72fdf3c31ceff5fd5ad751befe211ed5c81b7e8b8f0837e4bad993399dcfdabe639edffabf70b756dcbfcef69db5c04aa54ad0be679d93dab7bb9973fbe6eacfe37f8e1e91bb5f7f3576efd9fe42e7bb2d7547a7fd6723cc2f6abe5d3ea7b6f7fefde2b576602e3535bd69c9be6d5e631c8feddec92edcd7001dea6a9fb263526ef7f6d9779e07",
15
"difficulty": "0x2450fb34e3ea2a",
16
"number": "0xce1986",
17
"gasLimit": "0x1caa0e3",
18
"gasUsed": "0x1ca5d1c",
19
"timestamp": "0x617ad6f1",
20
"extraData": "0x486976656f6e20686b",
21
"mixHash": "0xe9baa71cbaa92d9d417dd083473fc658b2f6ad0e32f2598c4f46353d64869354",
22
"nonce": "0x97b7dbe2862da2df"
23
},
24
"transactions": [
25
{
26
"type": "0x2",
27
"nonce": "0x1714",
28
"gas": "0x206f3",
29
"value": "0x6f05b59d3b200000",
30
"input": "0x52bbbe2900000000000000000000000000000000000000000000000000000000000000e000000000000000000000000013b3a50f3947476eda74fe191344524e2d2d28e5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000013b3a50f3947476eda74fe191344524e2d2d28e500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000548139461270ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9212b088d48fc749c5adc573b445bc0d0a289a340002000000000000000000b100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000507586012a126421c3669a64b8393fffa9c444620000000000000000000000000000000000000000000000006f05b59d3b20000000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000",
31
"v": "0x0",
32
"r": "0xe2261a38f685e318164196727d41c91e497430b3bfd326a71c0bfbec747dcbd6",
33
"s": "0x2d9e98d07f053c4a5ea56ee1a1af3f7fb81bc22bcbb152fd847af12ff5e54bfa",
34
"to": "0xba12222222228d8ba445958a75a0704d566bf2c8",
35
"from": "0x13b3a50f3947476eda74fe191344524e2d2d28e5",
36
"gasPrice": null,
37
"hash": "0xf83aa79d4dd6f28bc127b12caf891f61e2e8fdc0b900211dd9c3dcae187fdf37",
38
"chainId": "0x1",
39
"accessList": [
40
41
],
42
"maxFeePerGas": "0x38e3aebfe4",
43
"maxPriorityFeePerGas": "0x6ccc91d0"
44
},
45
......
46
{
47
"type": "0x2",
48
"nonce": "0x2e8",
49
"gas": "0x5208",
50
"value": "0xbced73479b86000",
51
"input": "0x",
52
"v": "0x0",
53
"r": "0x46d725064ee3fac9bbb3df1bde7d419b9adc9b1204338df91938d742aa11d1ba",
54
"s": "0x68b7f00d0dcb65153db2af9d1458dc82a8deb65c0b2a52e11b46d8657600d9f6",
55
"to": "0x664cbf2a5b1bc7a9c153ae12f6ba7cefa4d1a482",
56
"from": "0x5907f6596de3235d9a1ddcf4e23535257e88d592",
57
"gasPrice": null,
58
"hash": "0xf131d507635a87a89d410f053ac83d18979b2c24106f322ac5285f67ebf05c30",
59
"chainId": "0x1",
60
"accessList": [
61
62
],
63
"maxFeePerGas": "0x41a7d25afc",
64
"maxPriorityFeePerGas": "0x68fdbaca"
65
}
66
]
67
}
68
},
69
"jsonrpc": "2.0"
70
}
71
​
Copied!
Copy link
Contents