Logo
New RPC users get 35% off their first monthView the offer
RPC Assistant

What is the RPC URL for Binance Smart Chain?

Summary

The official public RPC URL for BNB Smart Chain is https://bnb.api.onfinality.io/public. This endpoint lets you query the BNB Smart Chain mainnet without running your own node. For production workloads, you should evaluate managed and dedicated RPC options that offer higher rate limits, archive data, and WebSocket support.

Quick Answer: BNB Smart Chain RPC URL

The public RPC URL for BNB Smart Chain (mainnet) is:

https://bnb.api.onfinality.io/public

This endpoint is operated by OnFinality and allows you to send JSON-RPC requests to the BNB Smart Chain network without running your own node. It supports both HTTP and WebSocket transports.

For the BNB Smart Chain testnet, the public RPC URL is:

https://bnb-testnet.api.onfinality.io/public

Use the testnet endpoint for development and testing before deploying to mainnet.

Chain Settings at a Glance

When configuring your wallet or dApp, you need the following network details for BNB Smart Chain mainnet:

SettingValue
Network NameBNB Smart Chain Mainnet
RPC URLhttps://bnb.api.onfinality.io/public
Chain ID56
Currency SymbolBNB
Block Explorerhttps://bscscan.com

For the testnet, use:

SettingValue
Network NameBNB Smart Chain Testnet
RPC URLhttps://bnb-testnet.api.onfinality.io/public
Chain ID97
Currency SymboltBNB
Block Explorerhttps://testnet.bscscan.com

How to Connect to BNB Smart Chain

Using MetaMask

  1. Open MetaMask and click the network selector at the top.
  2. Click Add Network.
  3. Enter the mainnet settings from the table above.
  4. Save and switch to the new network.

Using ethers.js

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

const provider = new ethers.JsonRpcProvider("https://bnb.api.onfinality.io/public");

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

getBlockNumber();

Using viem

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

const client = createPublicClient({
  chain: bsc,
  transport: http("https://bnb.api.onfinality.io/public"),
});

const blockNumber = await client.getBlockNumber();
console.log("Current block number:", blockNumber);

Public vs. Managed vs. Dedicated RPC

The public RPC URL is a shared endpoint that is free to use, but it has rate limits and is not suitable for production applications with high traffic. For production, you have two main options:

  • Managed RPC: OnFinality provides managed RPC endpoints with higher rate limits, archive data, and WebSocket support. You pay per request and can scale as needed.
  • Dedicated Node: A dedicated node gives you exclusive access to a BNB Smart Chain node, with clear rate limits and full control over the node configuration. This is ideal for high-throughput workloads.

Decision Guide: Which Option Should You Choose?

WorkloadRecommended Option
Quick prototyping, hackathonsPublic RPC
Production dApp with moderate trafficManaged RPC
High-frequency trading, indexing, analyticsDedicated Node
Need archive data or trace methodsManaged RPC with archive support

If you are unsure, start with the public RPC for development, then move to a managed or dedicated solution as your traffic grows. OnFinality offers both managed RPC and dedicated nodes for BNB Smart Chain. See RPC pricing for details.

Common RPC Methods for BNB Smart Chain

BNB Smart Chain is Ethereum-compatible, so you can use standard Ethereum JSON-RPC methods. Here are a few common ones:

  • eth_blockNumber – get the latest block number
  • eth_getBalance – get the balance of an address
  • eth_call – execute a read-only contract call
  • eth_getLogs – fetch logs for a contract or topic
  • eth_sendRawTransaction – broadcast a signed transaction

Example using curl:

curl -X POST https://bnb.api.onfinality.io/public \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'

Troubleshooting Connection Issues

If you cannot connect to the RPC URL, check the following:

  • Network configuration: Ensure the chain ID and RPC URL are correct.
  • Rate limits: Public endpoints have rate limits. If you get 429 Too Many Requests, wait and retry, or use a managed endpoint.
  • CORS: If you are calling from a browser, the endpoint must support CORS. OnFinality public endpoints do.
  • WebSocket: For real-time updates, use the WebSocket URL: wss://bnb.api.onfinality.io/public/ws (check the exact URL on the BNB Chain network page).

Key Takeaways

  • The public RPC URL for BNB Smart Chain mainnet is https://bnb.api.onfinality.io/public.
  • The testnet RPC URL is https://bnb-testnet.api.onfinality.io/public.
  • Use the correct chain ID: 56 for mainnet, 97 for testnet.
  • For production, consider managed RPC or dedicated nodes to avoid rate limits and get better performance.
  • OnFinality supports both HTTP and WebSocket for BNB Smart Chain.

Frequently Asked Questions

What is the RPC URL for Binance Smart Chain?

The public RPC URL is https://bnb.api.onfinality.io/public. For the testnet, use https://bnb-testnet.api.onfinality.io/public.

Can I use the public RPC for production?

The public RPC is rate-limited and not recommended for production. Use a managed RPC or dedicated node for reliable performance.

How do I add BNB Smart Chain to MetaMask?

Use the network settings from the table above: RPC URL, chain ID 56, symbol BNB, and explorer https://bscscan.com.

Does OnFinality support WebSocket for BNB Smart Chain?

Yes, OnFinality supports WebSocket for BNB Smart Chain. Check the network page for the exact WebSocket URL.

What is the difference between BNB Smart Chain and BNB Chain?

BNB Smart Chain is the EVM-compatible blockchain that runs in parallel with BNB Beacon Chain. The RPC URL in this article is for BNB Smart Chain mainnet.

For more information on supported networks, see supported RPC networks.

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