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

txReceipts

Only available on Go Gateways.

PrevioustransactionStatusNextnewBlocks

Note: Gateway must have a node connection to both Consensus Layer and Execution Layer as well as be using the eth-ws-uristartup argument (see ).

Name: txReceipts

txReceipts is a stream of all transaction receipts in each newly mined block.

Options

i.e receipt.block_hash .

Key

Description

Values

include

Fields to include in the receipts stream

block_hash, block_number, contract_address, cumulative_gas_used, from, gas_used, logs, logs_bloom, status, to, transaction_hash, transaction_index, blob_gas_used, blob_gas_price[Default: all]

Examples - Websocket

Code Examples

wscat -c ws://127.0.0.1:28333/ws --header "Authorization: <YOUR-AUTHORIZATION-HEADER>"
> {"id": 1, "method": "subscribe", "params": ["txReceipts", {"include": []}]}
< ......
var fs = require('fs');
const WebSocket = require('ws');

 const ws = new WebSocket(
   "ws://127.0.0.1:28333/ws", 
   {
     headers: { 
       "Authorization" : <YOUR-AUTHORIZATION-HEADER>
     },
     rejectUnauthorized: false,
   }
 );

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


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

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

Go Gateway

import asyncio, json, websockets

async def main():
    try:
        uri = "ws://127.0.0.1:28333/ws"
        auth_key = "YOUR_AUTHORIZATION_HEADER"
        subscription_request = {
            "jsonrpc": "2.0",
            "id": 1,
            "method": "subscribe",
            "params": [
                "txReceipts",
                {
                    "include": []
                }
            ]
        }
        async with websockets.connect(
            uri,
            header=["Authorization:{}".format(auth_key)],            
            sslopt={"cert_reqs": ssl.CERT_NONE},
        ) as websocket:
            await websocket.send(json.dumps(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())
package main

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

func main() {
	tlsConfig := &tls.Config{
		InsecureSkipVerify: true,
	}
	dialer := websocket.DefaultDialer
	dialer.TLSClientConfig = tlsConfig
	wsSubscriber, _, err := dialer.Dial("ws://127.0.0.1:28333/ws", http.Header{"Authorization": []string{<YOUR-AUTHORIZATION-HEADER>}})

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

	subRequest := `{"id": 1, "method": "subscribe", "params": ["txReceipts", {"include": []}]}`
	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
	}
}

Response Example

<<< {"jsonrpc": "2.0", "id": null,
     "result": {"blockHash":"0x1580cb....c950122b837",
                "blockNumber":"0xb128cc",
                "contractAddress":null,
                "cumulativeGasUsed":"0x4e1fb7",
                "from":"0x80bb1...7bf44058a48a",
                "gasUsed":"0x1d918",
                "blob_gas_used":"0x1ba2"
                "blob_gas_price":"0x1fa3"
                "logs":[{"address":"0x68caa...87846652822ae4b5",
                         "topics":["0x3ae9ad...c40b5a","0x000000000...058a48a"],
                         "data":"0x0000...f3784",
                         "blockNumber":"0xb128cc",
                         "transactionHash":"0x12316c...3080bc012",
                         "transactionIndex":"0x4b",
                         "blockHash":"0x1580cb8419...22b837",
                         "logIndex":"0x7a",
                         "removed":false}],
                "logsBloom":"0x00000...0000",
                "status":"0x1",
                "to":"0x68ca...22ae4b5",
                "transactionHash":"0x12316...0bc012",
                "transactionIndex":"0x4b",
                "type":"0x0"}}

Examples - gRPC

Subscribing to Gateway txReceipts Stream in Go using gRPC

package main

import (
	"context"
	"fmt"
	pb "github.com/bloXroute-Labs/gateway/v2/protobuf"
	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials"
	"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
	
	// this will use localhost CA to verify the certificate
	creds := credentials.NewClientTLSFromCert(nil, "")

	// Open gRPC connection to Gateway.
	conn, _ := grpc.Dial(
		fmt.Sprintf("%v:%v", gatewayHostIP, gatewayGRPCPort),
		grpc.WithTransportCredentials(creds),
		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.TxReceipts(callContext, &pb.TxReceiptsRequest{})

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

Response (txReceipt Event)

{
    "logs": [
        {
            "topics": [],
            "address": "0x8c5ac30834d3...3232bb0a9ca2db0",
            "data": "0x0000000000000000000...94adc4863a85200000",
            "block_number": "0x107365",
            "transaction_hash": "0x1421194a1bb75...7e647943a1ca",
            "transaction_index": "0x6",
            "block_hash": "0x0d5fc0835...a0aec764",
            "log_index": "0x262",
            "removed": false
        },
        {
            "topics": [],
            "address": "0x8c5ac30834d3...0a9ca2db0",
            "data": "0x000000000000000000...726b7177a80000",
            "block_number": "0x107365",
            "transaction_hash": "0x1421194a1bb...943a1ca",
            "transaction_index": "0x6",
            "block_hash": "0x0d5fc0835ae3e3a5f96d...810d9ee8a0aec764",
            "log_index": "0x263",
            "removed": false
        },
        {
            "topics": [],
            "address": "0x41e574f051b...d6936c4488",
            "data": "0x62f5ce0e56677b23bf2...000000000000",
            "block_number": "0x107365",
            "transaction_hash": "0x1421194a1bb75128c16d5b...600f57e647943a1ca",
            "transaction_index": "0x6",
            "block_hash": "0x0d5fc0835ae3e3a...fdd9810d9ee8a0aec764",
            "log_index": "0x264",
            "removed": false
        },
        {
            "topics": [],
            "address": "0xb20bb9105e...8f736b77",
            "data": "0x0000000000000000000000...00000000000000000000000",
            "block_number": "0x107365",
            "transaction_hash": "0x1421194a1bb7512...e647943a1ca",
            "transaction_index": "0x6",
            "block_hash": "0x0d5fc0835ae3e3a5f...810d9ee8a0aec764",
            "log_index": "0x265",
            "removed": false
        }
    ],
    "blocK_hash": "0x0d5fc0835ae3e3a5f9...e8a0aec764",
    "block_number": "0x107365",
    "contract_address": "",
    "cumulative_gas_used": "0x177558a",
    "effective_gas_used": "0x3b9aca1a",
    "from": "0xe1e21059477182...eed361c",
    "gas_used": "0x53413",
    "logs_bloom": "0x80000000080000000000000000000000...00000000000",
    "status": "0x1",
    "to": "0xb20bb9105e007...a2c8f736b77",
    "transaction_hash": "0x1421194a1bb75128...f5600f57e647943a1ca",
    "transaction_index": "0x6",
    "type": "0x2",
    "txs_count": "0x9",
    "blob_gas_used": "",
    "blob_gas_price": ""
}
How to connect Go-Gateway to consensus layer