Logo
RPC Assistant

BNB Chain RPC: How to Connect, Configure, and Choose an Endpoint

Summary

BNB Chain RPC endpoints let applications read and write data on the BNB Smart Chain. This article explains the chain settings, how to add BNB Chain to a wallet, and how to evaluate RPC providers for production workloads.

Quick Decision Guide: Which BNB Chain RPC Should You Use?

Before you copy an endpoint into your wallet or application, decide what you need from the RPC provider. For simple wallet interactions or light dApp usage, a public endpoint may be enough. For production applications that depend on consistent throughput, low latency, and reliable access to historical data, a managed RPC service or a dedicated node is usually a safer choice.

Ask yourself these questions:

  • Do you need to handle high request volumes? Public endpoints often have rate limits that can throttle your application. If you expect spikes in traffic, a provider with scalable plans is better.
  • Do you need WebSocket support for real-time updates? Many public endpoints offer WebSocket, but reliability can vary. For trading bots or live dashboards, a provider with dedicated WebSocket support is recommended.
  • Do you need archive data or trace methods? If your application queries historical states or uses debug_traceTransaction, you need an archive node. Not all providers offer archive data, and it usually costs more.
  • Do you need to comply with data privacy or geographic requirements? Some providers offer endpoints in specific regions or with privacy features. Consider where your users are located.

If you are building a production application, evaluate providers based on uptime, throughput, and support. OnFinality offers managed RPC endpoints for BNB Chain and many other networks, with flexible pricing and a list of supported networks.

BNB Chain Network Settings at a Glance

BNB Smart Chain (BSC) is an EVM-compatible blockchain, so it uses the same JSON-RPC interface as Ethereum. Here are the key network parameters you need to configure a wallet or application:

ParameterValue
Network NameBNB Smart Chain Mainnet
Chain ID56 (0x38)
Currency SymbolBNB
Block Explorerhttps://bscscan.com
RPC URL (public)https://bsc-dataseed.bnbchain.org
WebSocket URL (public)wss://bsc-ws-node.nariber.org

For the testnet, the chain ID is 97 (0x61) and the explorer is https://testnet.bscscan.com. You can find more details on the BNB Chain testnet page.

Adding BNB Chain to MetaMask or Other Wallets

To interact with BNB Chain dApps, you need to add the network to your wallet. Here is how to do it manually in MetaMask:

  1. Open MetaMask and click the network dropdown at the top.
  2. Click Add Network.
  3. Fill in the network details:
    • Network Name: BNB Smart Chain
    • New RPC URL: https://bsc-dataseed.bnbchain.org
    • Chain ID: 56
    • Currency Symbol: BNB
    • Block Explorer URL: https://bscscan.com
  4. Click Save.

You can also use ChainList to add the network automatically. Visit chainlist.org/chain/56 and connect your wallet.

Making Your First JSON-RPC Request

Once you have an endpoint, you can test it with a simple curl command. The following example sends a eth_blockNumber request to the public BNB Chain RPC:

curl -X POST https://bsc-dataseed.bnbchain.org \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'

You should receive a response like:

{"jsonrpc":"2.0","id":1,"result":"0x6d8b8a"}

The result is the current block number in hexadecimal. You can convert it to decimal using parseInt(result, 16) in JavaScript.

Using BNB Chain RPC with ethers.js or viem

For JavaScript applications, you can use libraries like ethers.js or viem to connect to BNB Chain. Here is an example using ethers.js:

const { ethers } = require("ethers");

const provider = new ethers.JsonRpcProvider("https://bsc-dataseed.bnbchain.org");

async function getBlockNumber() {
  const blockNumber = await provider.getBlockNumber();
  console.log("Current block number:", blockNumber);
}

getBlockNumber();

With viem:

import { createPublicClient, http } from 'viem';
import { bsc } from 'viem/chains';

const client = createPublicClient({
  chain: bsc,
  transport: http('https://bsc-dataseed.bnbchain.org')
});

const blockNumber = await client.getBlockNumber();
console.log(blockNumber);

Understanding Rate Limits and Public Endpoints

Public BNB Chain endpoints are free but come with rate limits. The official documentation states a limit of 10,000 requests per 5 minutes per IP. Additionally, eth_getLogs is disabled on some public endpoints to prevent abuse. If your application relies on fetching logs, you should use a provider that supports this method or use WebSocket subscriptions to receive new logs in real time.

Public endpoints can also become congested during high network activity, leading to slower responses or timeouts. For production applications, relying solely on public endpoints is risky.

Evaluating RPC Providers for BNB Chain

When choosing an RPC provider for BNB Chain, consider the following criteria:

CriterionWhat to CheckWhy It Matters
ThroughputRequest limits, burst capacityPrevents throttling during traffic spikes
LatencyGeographic distribution, response timesAffects user experience, especially for time-sensitive apps
ReliabilityUptime history, redundancyEnsures your app stays available
Data AccessArchive data, trace methods, WebSocketNeeded for analytics, debugging, and real-time features
SupportSLAs, documentation, communityHelps resolve issues quickly
PricingFree tier, pay-as-you-go, dedicated optionsAligns with your budget and scaling needs

OnFinality provides managed RPC endpoints for BNB Chain with multiple regions and flexible plans. You can view the BNB Chain network page for more details, or explore RPC pricing to find a plan that fits your workload.

Common Pitfalls and Troubleshooting

  • Incorrect Chain ID: Using the wrong chain ID (e.g., 97 for testnet) will cause transactions to fail or be sent to the wrong network.
  • Rate Limiting: If you receive 429 Too Many Requests, you are hitting the rate limit. Consider upgrading your provider plan or implementing caching.
  • eth_getLogs Disabled: Some public endpoints disable this method. Use a provider that supports it or switch to WebSocket subscriptions.
  • WebSocket Connection Drops: If your WebSocket connection drops frequently, check your network stability and consider using a provider with dedicated WebSocket support.
  • Block Not Found: When querying a block that is too recent, the node may not have synced it yet. Wait a few seconds and retry.

When to Consider a Dedicated Node

If your application requires high throughput, low latency, or access to archive data, a dedicated BNB Chain node might be the right choice. Dedicated nodes give you exclusive access to the node, eliminating contention with other users. This is especially important for applications that process many transactions or need to query large amounts of historical data.

OnFinality offers dedicated node services for BNB Chain and other networks. You can choose the hardware and configuration that matches your needs, and scale as your application grows.

Key Takeaways

  • BNB Chain is an EVM-compatible network with chain ID 56 and BNB as the native currency.
  • Public RPC endpoints are free but have rate limits and may disable certain methods like eth_getLogs.
  • For production applications, evaluate providers based on throughput, latency, reliability, data access, and support.
  • Use WebSocket for real-time data and consider archive nodes for historical queries.
  • OnFinality provides managed RPC and dedicated node options for BNB Chain, with transparent pricing and a list of supported networks.

Frequently Asked Questions

What is the BNB Chain RPC URL?

The public RPC URL for BNB Smart Chain mainnet is https://bsc-dataseed.bnbchain.org. For testnet, use https://data-seed-prebsc-1-s1.bnbchain.org:8545.

How do I add BNB Chain to MetaMask?

Go to Settings > Networks > Add Network, and enter the network details: Chain ID 56, RPC URL https://bsc-dataseed.bnbchain.org, symbol BNB, and explorer https://bscscan.com.

Why is my BNB Chain RPC request failing?

Check your internet connection, ensure you are using the correct endpoint, and verify that you are not exceeding rate limits. If the issue persists, try a different provider.

Can I use WebSocket with BNB Chain?

Yes, BNB Chain supports WebSocket endpoints. For example, wss://bsc-ws-node.nariber.org is a public WebSocket endpoint. For production, consider a provider with dedicated WebSocket support.

Does OnFinality support BNB Chain?

Yes, OnFinality provides managed RPC endpoints for BNB Chain. Visit the BNB Chain network page for more information.

RPC Knowledge Base

Related RPC details

Never Worry about Infrastructure Again

OnFinality takes away the heavy lifting of DevOps so you can build smarter and faster.

Get Started