Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/BlockRazorinc/docs_en/llms.txt

Use this file to discover all available pages before exploring further.

The BSC Network Fee Stream gives your application a continuous, low-latency feed of current gas prices on the BNB Smart Chain, derived from recent historical block data. Rather than polling eth_gasPrice on demand and risking stale data during periods of network congestion, you receive pushed updates the moment fee conditions change. The service exposes three methods — GetGasPriceStream, GetAllGasPriceStream, and Sandwich Detector — all accessible over gRPC or WebSocket. Pricing is $500 per month.
Gas price data is computed from recent block history and pending mempool observations, not from a fixed oracle. This means the values you receive reflect live network conditions and update continuously as BSC validators produce new blocks.

Connection Details

PropertyValue
ProtocolgRPC or WebSocket (WSS)
gRPC hostgrpc.blockrazor.io:443
Pricing$500 / month
ChainBNB Smart Chain (BSC)
For gRPC connections, attach your auth token as a Bearer token in the authorization metadata header. For WebSocket connections, pass it as ?auth=YOUR_AUTH_TOKEN in the query string.

Methods

GetGasPriceStream

GetGasPriceStream streams the single current recommended gas price for BSC transactions. Each message contains the latest gas price in wei alongside a timestamp, providing a simple and accurate signal for setting transaction fees without overpaying during normal conditions.

Go gRPC Example

package main

import (
	"context"
	"fmt"
	"log"

	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials"
	"google.golang.org/grpc/metadata"
	pb "github.com/blockrazor/proto/gasfee"
)

func main() {
	// Establish TLS gRPC connection to BlockRazor
	conn, err := grpc.Dial(
		"grpc.blockrazor.io:443",
		grpc.WithTransportCredentials(credentials.NewTLS(nil)),
	)
	if err != nil {
		log.Fatal("gRPC dial error:", err)
	}
	defer conn.Close()

	client := pb.NewGasPriceServiceClient(conn)

	// Attach auth token to outgoing context
	ctx := metadata.AppendToOutgoingContext(
		context.Background(),
		"authorization", "Bearer YOUR_AUTH_TOKEN",
	)

	// Open the gas price stream
	stream, err := client.GetGasPriceStream(ctx, &pb.GasPriceRequest{})
	if err != nil {
		log.Fatal("stream error:", err)
	}

	fmt.Println("Streaming BSC gas prices...")
	for {
		resp, err := stream.Recv()
		if err != nil {
			log.Println("stream ended:", err)
			break
		}
		fmt.Printf("Gas price: %s wei  timestamp: %s\n",
			resp.GasPrice, resp.Timestamp)
	}
}

Response Fields

gasPrice
string
required
Current recommended gas price expressed as a decimal string in wei (e.g. "5000000000" for 5 Gwei). Use this value directly in your transaction’s gasPrice field.
timestamp
string
required
Unix timestamp (seconds) at which this gas price observation was recorded, as a decimal string (e.g. "1712345678").

Example Message

{
  "gasPrice": "5000000000",
  "timestamp": "1712345678"
}
Add a small buffer (e.g. 10–20%) on top of gasPrice during high-congestion periods to improve inclusion probability in the next block. The Sandwich Detector (below) can signal when MEV activity is elevated, which often correlates with fee spikes.

Sandwich Detector

The Sandwich Detector analyzes BSC mempool data in real time and identifies sandwich attack patterns — sequences where a bot places buy-side and sell-side transactions around a victim transaction to extract value through price impact. When a pattern is detected, the service emits a structured alert containing details about the attacker and victim transactions.
The Sandwich Detector is included in the BSC Network Fee Stream subscription at no additional cost. It operates on the same mempool feed as the gas price stream and shares the same gRPC connection.
Detected sandwich events include:
  • frontrunTxHash — the attacker’s buy-side transaction placed before the victim.
  • victimTxHash — the targeted user transaction being sandwiched.
  • backrunTxHash — the attacker’s sell-side transaction placed after the victim.
  • estimatedProfit — approximate value extracted by the sandwicher, expressed in BNB wei.
  • timestamp — Unix timestamp when the sandwich pattern was detected.

Example Sandwich Event

{
  "type": "sandwich",
  "frontrunTxHash": "0xa1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2",
  "victimTxHash":   "0xb2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3",
  "backrunTxHash":  "0xc3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4",
  "estimatedProfit": "1500000000000000",
  "timestamp": "1712345680"
}

Pricing & Discounts

Subscription PeriodPriceDiscount
1 month$500/month
3 months$500/month5% off
6 months$500/month10% off
9 months$500/month15% off
12 months$500/month20% off

Build docs developers (and LLMs) love