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
| Property | Value |
|---|
| Protocol | gRPC or WebSocket (WSS) |
| gRPC host | grpc.blockrazor.io:443 |
| Pricing | $500 / month |
| Chain | BNB 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
GetAllGasPriceStream
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
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.
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.
GetAllGasPriceStream
GetAllGasPriceStream streams all gas price tiers simultaneously — slow, standard, and fast — giving you a complete view of the current fee market. This is useful for applications that let users choose their own speed-vs-cost tradeoff, or for fee estimation logic that adapts dynamically to network 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() {
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)
ctx := metadata.AppendToOutgoingContext(
context.Background(),
"authorization", "Bearer YOUR_AUTH_TOKEN",
)
// Open the all-tiers gas price stream
stream, err := client.GetAllGasPriceStream(ctx, &pb.AllGasPriceRequest{})
if err != nil {
log.Fatal("stream error:", err)
}
fmt.Println("Streaming BSC all gas price tiers...")
for {
resp, err := stream.Recv()
if err != nil {
log.Println("stream ended:", err)
break
}
fmt.Printf(
"slow: %s wei standard: %s wei fast: %s wei ts: %s\n",
resp.Slow, resp.Standard, resp.Fast, resp.Timestamp,
)
}
}
Response Fields
Gas price (in wei) sufficient for inclusion within the next several blocks under normal network conditions. Lowest cost option.
Gas price (in wei) targeting inclusion within the next 1–3 blocks. Balances cost and speed for most use cases.
Gas price (in wei) optimized for inclusion in the very next block. Highest cost, lowest latency.
Unix timestamp (seconds) at which these tier prices were computed, as a decimal string.
Example Message
{
"slow": "3000000000",
"standard": "5000000000",
"fast": "8000000000",
"timestamp": "1712345679"
}
Map slow, standard, and fast directly to UI labels like “Economy”, “Standard”, and “Fast” in your wallet or dApp fee picker. Update the displayed values every time a new message arrives — no polling needed.
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 Period | Price | Discount |
|---|
| 1 month | $500/month | — |
| 3 months | $500/month | 5% off |
| 6 months | $500/month | 10% off |
| 9 months | $500/month | 15% off |
| 12 months | $500/month | 20% off |