githubEdit

How to Subscribe to Stream

Learn how to direct real-time access to transaction and block streams sourced from the BDN, bypassing RPC node-level execution and processing entirely.

Stream subscription provides you with direct access to blockchain data as it propagates through the BDN network. This is very good for users e.g traders who want to get data earlier e.g new released token With a stream subscription, you enjoy:

  • Faster blocks: Receive new blocks before standard RPC propagation

  • Mempool access: See pending transactions before they're mined

  • Lower latency: Edge infrastructure minimizes network hops

Code Sample

Here, you will be checking if you are connected to streams

wss://go.getblock.asia/<ACCESS_TOKEN>

How to Subscribe to Streams

To subscribe to streams, there are four parameters you can make use of as seen below:

Stream
Description
Use Case

bdnBlocks

New blocks with headers and transactions

Block monitoring, analytics

newTxs

New transactions entering mempool

MEV detection, copy trading

pendingTxs

Pending transactions

Front-running protection

txReceipts

Transaction receipts after confirmation

Trade confirmation

1. Block Streams (bdnBlocks)

Subscribe to new blocks as they're produced.

Include Options

Field
Description

header

Block header (number, hash, timestamp, gasUsed, gasLimit)

transactions

Full transaction list

hash

Block hash only

Example: Subscribe to Blocks

2. Transaction Streams (newTxs / pendingTxs)

Subscribe to mempool transactions as they propagate through the network.

Include Options

Field
Description

tx_hash

Transaction hash

from

Sender address

to

Recipient address

value

Transaction value (hex)

gas_price

Gas price (hex)

input

Transaction calldata

Filters

Reduce bandwidth by filtering server-side:

Filter
Type
Description

to

array

Transaction recipient addresses

from

array

Transaction sender addresses

method_id

array

Function selectors (first 4 bytes of calldata)

Example: Monitor PancakeSwap Transactions

3. Transaction Receipts (txReceipts)

Subscribe to transaction confirmations.

Include Options

Field
Description

receipt

Full transaction receipt

logs

Event logs emitted

Example:

Unsubscribing

To stop receiving notifications, unsubscribe using the subscription ID:

Best Practices

1. Request Only What You Need

  1. Use Server-Side Filters

  1. Handle Reconnection

  1. Process Messages Asynchronously

Rate Limits

Tier
Concurrent Subscriptions
Message Rate

Standard

5

1,000/sec

Pro

20

10,000/sec

Enterprise

Unlimited

Unlimited

Contact supportenvelope to upgrade your tier.

Troubleshooting

Problem
Solution

No messages received

  • Check subscription response—did you receive a subscription ID?

  • Verify filters aren't too restrictive

  • Confirm your API key is valid and active

High latency

  • Reduce the number of include fields

  • Add filters to reduce message volume

  • Check your network connection

Missed messages

  • Process messages asynchronously

  • Increase your message queue buffer

  • Consider multiple connections for different streams

Connection Drop

  • Implement automatic reconnection (see example above)

  • Re-subscribe after each reconnect—subscriptions don't persist

  • Check your network stability

Next Step

  1. Submitting transactions to public mempool with accelerated propagation

  2. Using private transactions for MEV protection or without MEV Protection

Last updated

Was this helpful?