bloXroute Documentation
WebsiteBlogTwitterDiscord
  • Welcome to bloXroute
  • Introduction
    • Why Use bloXroute?
    • Products
    • Create An Account
    • Technical Support
  • SOLANA
    • Trader API
      • Introduction
        • Regions
        • Authorization
        • Rate Limits
        • Tip and Tipping Addresses
      • Quick Start
        • Transaction Submission
        • Front-Running Protection & Transaction Bundle
        • Go SDK
        • Python SDK
        • Typescript SDK
        • Rust SDK
      • API Endpoints
        • Core Endpoints
          • submit
          • submit-paladin
          • submit-batch
          • balance
          • rate-limit
          • transaction
          • priority-fee
          • GetPriorityFeeStream
          • GetBundleTipStream
          • submit-snipe
        • Pump.fun
          • quotes
          • swap
          • swap-sol
          • GetPumpFunNewTokensStream
          • GetPumpFunSwapsStream
          • GetPumpFunAMMSwapsStream
        • Raydium
          • quotes
          • pools
          • pool-reserves
          • swap
          • cpmm-swap
          • clmm-swap
          • route-swap
          • GetPoolReservesStream
          • GetSwapsStream
          • GetNewRaydiumPoolsStream
          • GetNewRaydiumPoolsByTransactionStream
        • Jupiter
          • quotes
          • swap
          • swap-instructions
          • route-swap
        • Openbook
          • markets
          • orderbooks/{market}
          • depth/{market}
          • tickers/{market}
          • open-orders/{market}
          • unsettled/{market}
          • place
          • replace
          • cancel
          • settle
          • GetOrderbooksStream
          • GetTickersStream
      • Best Performance for Landing Transactions
      • Support
        • API Health
        • Contact us
        • Suggestions
        • Wiki
          • Terms & Concepts
          • Resources
    • Optimized Feed Relay (OFR)
      • Transaction Streamer
      • Gateway and OFR Requirements
      • Gateway and OFR Setup
      • Gateway Startup Arguments
      • OFR performance
      • Logging
      • Submitting Transaction
      • Upgrading Gateway
      • Troubleshooting
  • BSC & ETH
    • EVM Blockchain Distribution Network (BDN)
      • How to Connect
      • The bloXroute Gateway
        • Local Gateway
          • Installation and Startup
            • Authentication & Certificates
            • Requirements
            • Supported Clients
            • GitHub repository option
            • Docker container option
            • Startup Script
            • Startup Arguments
          • General Connectivity Troubleshooting
          • Logging
          • Upgrading your Gateway
        • Add Your Gateway as a Trusted Peer to Your Execution Layer Client
        • Connecting Your Gateway with the Consensus Layer
      • IPs & Relays
        • Relays IPs
        • Private Relays
        • Cloud-API IPs
          • ⏩Reducing Latencies using the BDN
    • APIs
      • Authorization
      • Check Transaction Quota
      • Submit a Transaction
        • Raw Transaction Construction
        • Tx-Validation
        • Batch Transaction
      • Private Transactions
        • ETH Private Transactions
        • BSC Private Transactions
      • Transaction Bundles
        • Bundle Simulation
        • Bundle Validation
        • Bundle Submission
          • BSC Bundle Submission
            • List of BSC Validators
          • ETH Bundle Submission
          • Bundle Submission with Gateway
        • Bundle Tracking
          • BSC Bundle-Trace
          • ETH Bundle-Trace
          • ETH Bundle Inclusion Status
        • Bundle Refunds
          • Priority Fee Refund
          • Bundle Refund
          • Latest Bundle Refunds
      • Backrun Arbitrage
        • BackRunMe: Bundle Submission
          • BSC submit arbOnly
          • ETH submit arbOnly
            • blxr_info
            • ETH arbOnly Simulation
      • Token Launch Sniping
      • Other Utilities
        • List of bloXroute Builders
        • List of External Builders
        • Tx-Trace
        • Ping
    • Streams
      • Requirements
      • Subscription limits
      • Working With Streams
        • Creating a Subscription
          • Websocket
          • gRPC
        • Handling the Notification
          • Websocket
          • gRPC
        • Cancelling a Subscription
          • Websocket
          • gRPC
        • Local Node Validation
      • newTxs and pendingTxs
        • Filters
        • Raw TX Reconstruction
      • BackRunMe: arbOnlyMEV
        • ETH arbOnlyMEV
        • BSC arbOnlyMEV
      • transactionStatus
      • txReceipts
      • newBlocks
      • bdnBlocks
      • ethOnBlock
      • MEVBlockValue
      • MEVNextProposerInfo
    • Block Builders and Validators
      • Validator Gateway
      • MEV Relay (For Validators)
      • Block Submission
      • Proposer MEV-Protect
      • Compliance Lists
      • Preconfirmations
    • Protect RPCs
      • ETH Protect RPC
      • ETH Gas Protect RPC
      • BSC Protect RPC
      • SOL Protect RPC
  • Base Network
    • Submit Transactions
    • Streams
      • GetBdnBlockStream
  • TON NETWORK
    • TON Trader API
      • Quick Start
      • Fee Schedule
      • Connection
      • Submit Signed Transaction
  • Resources
    • BDN Explorer
    • Block Explorer
    • Guides
      • Algorithmic Trading
      • Setting Up a Local Gateway
      • Gateway as Web3 Bridge
    • Architecture
      • BDN Architecture
        • Network Components
        • Performance Techniques
          • Block Compression
          • Cut-through Routing
          • Optimized Topology
      • bloXroute Protocol
        • Versioning
        • Message Structure
        • Message Types
    • Contact Us
Powered by GitBook
On this page
  • Examples (Websocket)
  • Examples - gRPC
  1. BSC & ETH
  2. Streams

bdnBlocks

Available on 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,future_validator_info,withdrawals

[Default: all] future_validator_info contains validator addresses for future blocks and indicates whether the validators are connected to the BDN (currently only supported in BSC) withdrawals

contains withdrawals for ETH block

Examples (Websocket)

Cloud-API

## ETH Example
wscat -c wss://virginia.eth.blxrbdn.com/ws --header "Authorization: <YOUR-AUTHORIZATION-HEADER>"
> {"jsonrpc": "2.0", "id": 1, "method": "subscribe", "params": ["bdnBlocks", {"include": ["hash"]}]}
< ......


## BSC Example
wscat -c wss://virginia.bsc.blxrbdn.com/ws --header "Authorization: <YOUR-AUTHORIZATION-HEADER>"
> {"jsonrpc": "2.0", "id": 1, "method": "subscribe", "params": ["bdnBlocks", {"include": ["hash"], "blockchain_network": "BSC-Mainnet"}]}
< ......
var fs = require('fs');
const WebSocket = require('ws');

// Enterprise users can follow line 5-16
const ws = new WebSocket(
  'wss://virginia.eth.blxrbdn.com/ws', // for ETH
  // use 'wss://virginia.bsc.blxrbdn.com/ws',     //for BSC
  {
    headers: { 
      "Authorization" : <YOUR-AUTHORIZATION-HEADER> 
    },
    // Add the following line if you work with IP instead of DNS
    // rejectUnauthorized: false,
  }
);

//  Non Enterprise users should follow line 19-27
//  const ws = new WebSocket(
//    "wss://api.blxrbdn.com/ws", 
//    {
//      headers: { 
//        "Authorization" : <YOUR-AUTHORIZATION-HEADER> 
//      },
//      rejectUnauthorized: false,
//    }
//  );

function proceed() {
    // ETH Example
    ws.send(`{"jsonrpc": "2.0", "id": 1, "method": "subscribe", "params": ["bdnBlocks", {"include": ["tx_hash"]}]}`);

    // BSC Example (only available at endpoint wss://<region>.bsc.blxrbdn.com/ws)
    // ws.send(`{"jsonrpc": "2.0", "id": 1, "method": "subscribe", "params": ["bdnBlocks", {"include": ["hash"], "blockchain_network": "BSC-Mainnet"}]}`);

}


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

ws.on('open', proceed);
ws.on('message', handle);
import asyncio, json, ssl, websockets

async def main():
    auth_key = "YOUR_AUTHORIZATION_HEADER"
    uri = 'wss://virginia.eth.blxrbdn.com/ws'
    # Non Enterprise users should use endpoint:
    # uri = 'wss://api.blxrbdn.com/ws'
    
    async with websockets.connect(
            uri,
            header=["Authorization:{}".format(auth_key)],            
            sslopt={"cert_reqs": ssl.CERT_NONE},
    ) as websocket:
        # ETH Example
        subscribe_request = {
            "jsonrpc": "2.0",
            "id": 1,
            "method": "subscribe",
            "params": ["bdnBlocks", {"include": ["hash"]}]
        }
        # BSC Example (only available at endpoint wss://<region>.bsc.blxrbdn.com/ws)
        # subscribe_request = {"jsonrpc": "2.0", "id": 1, "method": "subscribe", "params": ["bdnBlocks", {"include": ["hash"]}, "blockchain_network": "BSC-Mainnet"]}

        await websocket.send(json.dumps(subscribe_request))
        response = await websocket.recv()
        subscription_id = json.loads(response)["result"]

        while True:
            next_notification = await websocket.recv()
            print(next_notification)  # or process it generally

        unsubscribe_request = {
            "jsonrpc": "2.0",
            "id": 2,
            "method": "unsubscribe",
            "params": [subscription_id]
        }
        await websocket.send(json.dumps(unsubscribe_request))

if __name__ == '__main__':
    asyncio.run(main())
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

	// Enterprise users can follow line 20
	wsSubscriber, _, err := dialer.Dial("wss://virginia.eth.blxrbdn.com/ws", http.Header{"Authorization": []string{<YOUR-AUTHORIZATION-HEADER>}})

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

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

	// ETH Example
	subRequest := `{"id": 1, "method": "subscribe", "params": ["bdnBlocks", {"include": ["hash"]}]}`

	// BSC Example (only available at endpoint wss://<region>.bsc.feed.blxrbdn.com:28333)
	// subRequest := `{"id": 1, "method": "subscribe", "params": ["bdnBlocks", {"include": ["hash"], "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
	}
}

Gateway

wscat -c ws://127.0.0.1:28333/ws --header "Authorization: <YOUR-AUTHORIZATION-HEADER>"
> {"jsonrpc": "2.0", "id": 1, "method": "subscribe", "params": ["bdnBlocks", {"include": ["hash"]}]}
< ......

Response (Block Event)

<<< {
  "method": "subscribe",
  "params": {
    "subscription": "6ea43ccf-3810-11ec-ad71-0242ac110002",
    "result": {
      "hash": "0x95774a847277f19f85742740577812b33be5e8261b13ae0a93828b44401aac80",
      "header": {
        "parentHash": "0xf254c84238d1e5c9aca356a7ad01a7dc75c7012c8cb06a43510bdc486027374c",
        "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
        "miner": "0x1ad91ee08f21be3de0ba2ba6918e714da6b45836",
        "stateRoot": "0xa80ba46395c5cd93a2122296207ed5433a6f0bafdf31a9db43d641a7bc764e55",
        "transactionsRoot": "0x7588844493391e8503a966f4720d85f83a3e672e314a122db2bb6769b214c90b",
        "receiptsRoot": "0x8a6aaba9d857189db685a1bb9d179f1cdca9b1c06bd77ff851d31e90734c70bf",
        "logsBloom": "0xd0fa0757dcfb97f75b80a4f4ffc24bdef632117a9ebcbabb65abf679d77f5bbf96cdc19a58f142755d85db83ef7c13f61f6784706b41fbc9fe56fb2ab7ecedcfc9eeedd34149fd7f2ade66cf7df4f6f5928ba98cafde24ffa4e37fdfe0cc7dbf1fb5e43b42687836fc7c1e958f11edf47f77b9f2b0357e707a72fdf3c31ceff5fd5ad751befe211ed5c81b7e8b8f0837e4bad993399dcfdabe639edffabf70b756dcbfcef69db5c04aa54ad0be679d93dab7bb9973fbe6eacfe37f8e1e91bb5f7f3576efd9fe42e7bb2d7547a7fd6723cc2f6abe5d3ea7b6f7fefde2b576602e3535bd69c9be6d5e631c8feddec92edcd7001dea6a9fb263526ef7f6d9779e07",
        "difficulty": "0x2450fb34e3ea2a",
        "number": "0xce1986",
        "gasLimit": "0x1caa0e3",
        "gasUsed": "0x1ca5d1c",
        "timestamp": "0x617ad6f1",
        "extraData": "0x486976656f6e20686b",
        "mixHash": "0xe9baa71cbaa92d9d417dd083473fc658b2f6ad0e32f2598c4f46353d64869354",
        "nonce": "0x97b7dbe2862da2df"
        "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
          }
        ], 
       "withdrawals": [
           {
           "index": "0x1506516",
           "validatorIndex": "0x18ea9",
           "address": "0x8e609ac80f4324e499a6efd24f221a2caa868224",
           "amount": "0x379ea6b"
           },
           {
           "index": "0x1506517",
           "validatorIndex": "0x18eaa",
           "address": "0x8e609ac80f4324e499a6efd24f221a2caa868224",
           "amount": "0x102d9b3"
         }], 
      "transactions": [
        {
          "type": "0x2",
          "nonce": "0x1714",
          "gas": "0x206f3",
          "value": "0x6f05b59d3b200000",
          "input": "0x52bbbe2900000000000000000000000000000000000000000000000000000000000000e000000000000000000000000013b3a50f3947476eda74fe191344524e2d2d28e5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000013b3a50f3947476eda74fe191344524e2d2d28e500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000548139461270ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9212b088d48fc749c5adc573b445bc0d0a289a340002000000000000000000b100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000507586012a126421c3669a64b8393fffa9c444620000000000000000000000000000000000000000000000006f05b59d3b20000000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000",
          "v": "0x0",
          "r": "0xe2261a38f685e318164196727d41c91e497430b3bfd326a71c0bfbec747dcbd6",
          "s": "0x2d9e98d07f053c4a5ea56ee1a1af3f7fb81bc22bcbb152fd847af12ff5e54bfa",
          "to": "0xba12222222228d8ba445958a75a0704d566bf2c8",
          "from": "0x13b3a50f3947476eda74fe191344524e2d2d28e5",
          "gasPrice": null,
          "hash": "0xf83aa79d4dd6f28bc127b12caf891f61e2e8fdc0b900211dd9c3dcae187fdf37",
          "chainId": "0x1",
          "accessList": [
            
          ],
          "maxFeePerGas": "0x38e3aebfe4",
          "maxPriorityFeePerGas": "0x6ccc91d0"
        },
	......
        {
          "type": "0x2",
          "nonce": "0x2e8",
          "gas": "0x5208",
          "value": "0xbced73479b86000",
          "input": "0x",
          "v": "0x0",
          "r": "0x46d725064ee3fac9bbb3df1bde7d419b9adc9b1204338df91938d742aa11d1ba",
          "s": "0x68b7f00d0dcb65153db2af9d1458dc82a8deb65c0b2a52e11b46d8657600d9f6",
          "to": "0x664cbf2a5b1bc7a9c153ae12f6ba7cefa4d1a482",
          "from": "0x5907f6596de3235d9a1ddcf4e23535257e88d592",
          "gasPrice": null,
          "hash": "0xf131d507635a87a89d410f053ac83d18979b2c24106f322ac5285f67ebf05c30",
          "chainId": "0x1",
          "accessList": [
            
          ],
          "maxFeePerGas": "0x41a7d25afc",
          "maxPriorityFeePerGas": "0x68fdbaca"
        }
      ]
    }
  },
  "jsonrpc": "2.0"
}

Examples - gRPC

package main

import (
	"context"
	"fmt"
	pb "github.com/bloXroute-Labs/gateway/v2/protobuf"
	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials/insecure"
	"time"
)

type blxrCredentials struct {
	authorization string
}

func (bc blxrCredentials) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) {
	return map[string]string{
		"authorization": bc.authorization,
	}, nil
}

func (bc blxrCredentials) RequireTransportSecurity() bool {
	return false
}

func main() {
	// gRPC server default values
	gatewayHostIP := "localhost"
	gatewayGRPCPort := 5001

	// Open gRPC connection to Gateway.
	conn, _ := grpc.Dial(
		fmt.Sprintf("%v:%v", gatewayHostIP, gatewayGRPCPort),
		grpc.WithTransportCredentials(insecure.NewCredentials()),
		grpc.WithPerRPCCredentials(blxrCredentials{authorization: "<YOUR-AUTHORIZATION-HEADER>"}),
	)

	// Use the Gateway client connection interface.
	client := pb.NewGatewayClient(conn)

	// create context and defer cancel of context
	callContext, cancel := context.WithTimeout(context.Background(), 24*time.Hour)
	defer cancel()

	// Create a subscription using the stream-specific method and request.
	stream, _ := client.BdnBlocks(callContext, &pb.BlocksRequest{})

	for {
		subscriptionNotification, err := stream.Recv()
		if err == nil {
			fmt.Println(subscriptionNotification) // or process it generally
		}
	}
}

Response (Block Event)

{
    "future_validator_info": [],
    "transaction": [
        {
            "from": "",
            "local_region": false,
            "time": "0",
            "raw_tx": "+I6DAlTHhQHc1lHAglnYlBXsRrWI...3SFs7n3n3UUCAVX1weV6HLAcAKuA"
        },
        ....
        {
            "from": "",
            "local_region": false,
            "time": "0",
            "raw_tx": "AviPgkJogwkGOoQ7mso...3Z99ZUu1/Jc0B9ytQ="
        }
    ],
    "withdrawals": [
        {
            "address": "0x9baA3244565d51D9C7897c0EB6679eD4890e536E",
            "amount": "0x60077b",
            "index": "0x104ed81",
            "validator_index": "0x1ee90"
        },
        ....
        {
            "address": "0x9baA3244565d51D9C7897c0EB6679eD4890e536E",
            "amount": "0x604095",
            "index": "0x104ed90",
            "validator_index": "0x1ee9f"
        }
    ],
    "hash": "0xd9cfa479b98ae15...a7e629fe3435e6169abca",
    "subscriptionID": "c5451b97-c82c-47e2-a70e-74e3256584e6",
    "header": {
        "parent_hash": "0xf3fd6b6011eed8d...f482e9345a3fe5dfe9e26c1db",
        "sha3_uncles": "0x1dcc4de8dec75d7aa...48a7413f0a142fd40d49347",
        "miner": "0x0c10000000756...7f022929a97bda45",
        "state_root": "0xf074e94fc3d700a8f....9ea3280595bd5acd5d97d0",
        "transactions_root": "0xedade2fe2198c....ccf38eeaacb2ccaa92e60",
        "receipts_root": "0x2ff34bb52237c31b8...78e0ac369028cb63f",
        "logs_bloom": "0x4c0008000804...00402004048",
        "difficulty": "0x0",
        "number": "0x107336",
        "gas_limit": "0x1c9c380",
        "gas_used": "0x11bc8e3",
        "timestamp": "0x65e73b50",
        "extra_data": "0xd883010d0e846....2312e37856c696e7578",
        "mix_hash": "0xf6743b00bce48fc1617acf...84d781807a3866ab",
        "nonce": "0x0000000000000000",
        "base_fee_per_gas": "59",
        "withdrawals_root": "0x5e9855e2716a2b4793d4e...9faa41d9c876fcff1b",
        "blob_gas_used": "0x80000",
        "excess_blob_gas": "0x4b20000",
        "parent_beacon_root": "0xe83661292da71373c38...3a91a5e27ac4a59ea3c"
    }
}
PreviousnewBlocksNextethOnBlock