Logo
新用户订阅 RPC,首月享 6.5 折优惠查看优惠
RPC Assistant

What is the BNB RPC name and how do you configure it?

摘要

The BNB RPC name is the network label and chain identifier your wallet or library uses to connect to BNB Smart Chain. In practice this means the chain name (BNB Smart Chain), the RPC URL, the chain ID (56 for mainnet, 97 for testnet), the native currency symbol (BNB or tBNB), and the block explorer URL. Getting these values right is what stops "wrong network" and "unknown chain" errors.

This page gives you the exact mainnet and testnet settings, shows how to add the network in MetaMask and in code with ethers or viem, and explains how to pick an RPC endpoint that holds up under real traffic. OnFinality provides BNB Chain RPC API access and dedicated nodes when you need more control than a public endpoint offers.

When a wallet or library asks for the "BNB RPC name", it usually wants a small set of network parameters: the chain name, the RPC URL, the chain ID, the native currency, and the block explorer. Those values are what let a client identify BNB Smart Chain and route JSON-RPC calls to it. This page gives you the exact settings for mainnet and testnet, shows how to apply them in MetaMask and in code, and explains how to choose an endpoint that stays usable as your traffic grows.

Chain settings at a glance

Use these values when adding BNB Smart Chain to a wallet, a dApp network switcher, or a backend config. The chain ID is the field most tools actually use to disambiguate the network, so keep it consistent everywhere.

SettingBNB Smart Chain MainnetBNB Smart Chain Testnet
Network nameBNB Smart ChainBNB Smart Chain Testnet
Chain ID5697
Native currencyBNB (18 decimals)tBNB (18 decimals)
Block explorerhttps://bscscan.comhttps://testnet.bscscan.com
OnFinality public RPChttps://bnb.api.onfinality.io/publichttps://bnb-testnet.api.onfinality.io/public
TransportHTTP, WebSocketHTTP

A quick note on naming: people say "BNB RPC", "BSC RPC", and "BNB Chain RPC" interchangeably. They all refer to the same EVM-compatible chain. BNB Smart Chain is the current name; BSC is the older short form you will still see in tooling and docs. If a provider lists "BSC", treat it as the same network and check the chain ID to be sure.

Which endpoint should you actually connect to?

The RPC name is just a label. The endpoint behind it is what determines whether your app feels instant or flaky. Before you paste a URL into production, decide which category fits your workload.

  • Public endpoints are fine for local development, quick scripts, and low-volume reads. They are shared, so throughput and rate behavior are outside your control.
  • Managed RPC API access gives you a keyed endpoint with a defined service relationship, which is the usual choice for apps with real users.
  • Dedicated nodes give you isolated capacity for heavy eth_getLogs, archive queries, or high request volume where shared endpoints become a bottleneck.

If you are still deciding between these tiers, the RPC provider selection guide walks through the tradeoffs. For BNB Chain specifically, OnFinality's BNB Chain RPC covers both managed API access and dedicated node options, and RPC pricing shows how the tiers are structured.

Adding BNB Smart Chain to a wallet

Most wallets accept a custom network through the same five fields. In MetaMask, open Settings, then Networks, then Add a network manually, and enter the mainnet values from the table above. The chain ID 56 is what prevents the wallet from confusing BNB Smart Chain with another EVM chain.

You can also trigger the same flow from a dApp using wallet_addEthereumChain. This is the cleaner path because it lets your app request the network switch directly instead of asking users to type settings by hand.

const BNB_MAINNET = {
  chainId: '0x38', // 56 in hex
  chainName: 'BNB Smart Chain',
  nativeCurrency: { name: 'BNB', symbol: 'BNB', decimals: 18 },
  rpcUrls: ['https://bnb.api.onfinality.io/public'],
  blockExplorerUrls: ['https://bscscan.com'],
};

await window.ethereum.request({
  method: 'wallet_addEthereumChain',
  params: [BNB_MAINNET],
});

One detail that trips people up: chain IDs are passed as hex strings in wallet_addEthereumChain. Mainnet 56 becomes 0x38, and testnet 97 becomes 0x61. If you pass the decimal value, some wallets reject the request silently.

Wiring the endpoint into ethers or viem

In code, the RPC name matters less than the URL and chain ID you construct the client with. Both ethers and viem let you point at any endpoint, so the choice of provider is a config decision rather than a code rewrite.

import { JsonRpcProvider } from 'ethers';

const provider = new JsonRpcProvider(
  'https://bnb.api.onfinality.io/public',
  56 // chainId
);

const block = await provider.getBlockNumber();
console.log('BNB Smart Chain head:', block);

With viem, the same idea uses a chain definition plus a transport:

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

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

If you later move to a keyed or dedicated endpoint, you change the URL string and nothing else. Keeping the endpoint in an environment variable from day one makes that switch painless.

Verifying the connection with a raw JSON-RPC call

Before you debug application code, confirm the endpoint itself answers. A single eth_chainId call tells you whether you are talking to the chain you think you are.

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

The response should return 0x38 for mainnet. If you get 0x61, you are pointed at testnet. If the call times out or returns an error object, the problem is the endpoint or your network path, not your contract logic.

Common failure modes and how to read them

Most "BNB RPC name" problems are really configuration or endpoint problems wearing a confusing error message. Here is how to map symptoms to fixes.

SymptomLikely causeWhat to do
"Wrong network" in walletChain ID mismatchConfirm 56 (mainnet) or 97 (testnet)
chainId returns unexpected valueEndpoint points at a different chainRe-check the RPC URL against the table
Requests work, then start failingShared endpoint rate behaviorMove to a keyed or dedicated endpoint
eth_getLogs times outQuery range too wide or endpoint limitsNarrow the block range, or use a dedicated node
WebSocket disconnectsTransport not supported or idle timeoutConfirm the endpoint supports WS, add reconnect logic
Transactions stuck as pendingNonce or gas issue, not RPC namingInspect nonce and gas settings

That last row is worth separating out. A stuck transaction is usually a nonce or gas problem, not a network naming problem. If you are chasing that class of bug, the explanation of transaction nonces is a better starting point.

Mainnet versus testnet: keep them separate

Testnet uses chain ID 97 and the tBNB symbol, and it lives at a different endpoint. Mixing the two is one of the most common sources of confusion, because a dApp that hardcodes mainnet settings will fail quietly against testnet data.

A practical pattern is to define both networks in one config object and select by environment:

const NETWORKS = {
  mainnet: {
    chainId: 56,
    rpc: 'https://bnb.api.onfinality.io/public',
    explorer: 'https://bscscan.com',
  },
  testnet: {
    chainId: 97,
    rpc: 'https://bnb-testnet.api.onfinality.io/public',
    explorer: 'https://testnet.bscscan.com',
  },
};

const active = process.env.CHAIN_ENV === 'testnet'
  ? NETWORKS.testnet
  : NETWORKS.mainnet;

Testnet tBNB comes from a faucet rather than a purchase, so you can exercise contract deploys and transaction flows without spending real BNB. See the BNB Chain Testnet network page for the current endpoint details.

When a public endpoint stops being enough

Public endpoints are genuinely useful, and for a prototype they are often all you need. The friction appears when request volume, log queries, or WebSocket subscriptions grow. At that point the shared endpoint becomes a variable you cannot control, and debugging gets harder because failures are intermittent rather than consistent.

The usual progression is: public endpoint for development, a managed RPC API for staging and early production, then dedicated nodes once you have predictable heavy workloads such as indexers, analytics, or trading-adjacent services. OnFinality offers BNB Chain RPC API access and dedicated node infrastructure so you can move along that path without changing your application code, only the endpoint URL. You can review the full set of supported RPC networks if you also operate on other chains and want consistent tooling.

Key Takeaways

  • The BNB RPC name is a set of network parameters, not a single string. The important ones are chain name, RPC URL, chain ID, currency, and explorer.
  • Mainnet uses chain ID 56 and BNB; testnet uses chain ID 97 and tBNB. Keep them in separate config entries.
  • Chain IDs are hex strings in wallet_addEthereumChain: 0x38 for mainnet, 0x61 for testnet.
  • Verify any endpoint with a raw eth_chainId call before debugging application code.
  • Public endpoints suit development; managed RPC API access and dedicated nodes suit production traffic and heavy log queries.
  • BNB, BSC, and BNB Chain all refer to the same EVM-compatible network.

Frequently Asked Questions

What is the BNB RPC name?

It is the network label plus the parameters a client needs to reach BNB Smart Chain: the chain name (BNB Smart Chain), the RPC URL, the chain ID, the native currency, and the block explorer. Wallets and libraries use these together to identify and connect to the network.

What is the chain ID for BNB Smart Chain?

Mainnet is 56 and testnet is 97. In wallet_addEthereumChain requests these are written as hex strings, 0x38 and 0x61.

Is BSC the same as BNB Chain?

Yes. BSC was the earlier short name for BNB Smart Chain. The chain ID is the reliable way to confirm you are on the right network regardless of which label a provider uses.

Why does my wallet say wrong network?

The chain ID in your wallet config does not match the network you are trying to use. Check that mainnet is set to 56 and testnet to 97, and that the RPC URL matches the same network.

Can I use a public RPC endpoint in production?

You can, but shared endpoints give you limited control over throughput and rate behavior. For apps with real traffic, a managed RPC API or dedicated node is the more predictable option.

Does BNB Chain support WebSocket RPC?

Mainnet endpoints can support WebSocket transport for subscriptions, while testnet availability may differ. Confirm transport support on the specific endpoint you plan to use before building subscription logic around it.

RPC 知识库

相关 RPC 内容

网络 RPCAleph Zero

What is the Aleph Zero RPC endpoint and how do you connect?

Aleph Zero is a Layer 1 blockchain focusing on privacy and scalability using a novel consensus mechanism. Its RPC endpoint allows developers to intera...

RPC 故障排查

什么是加密中的 nonce?

# 什么是加密中的 nonce? Nonce(“一次性使用的数字”)是在加密通信中仅使用一次的独特任意数字。在像以太坊这样的区块链网络中,nonce 是一个顺序计数器,确保来自给定地址的交易按顺序处理,并防止重放攻击。每笔交易的 nonce 必须比同一账户的上一笔交易高 1;否则,网络会拒绝该交易。...

RPC 提供商选择Celo

如何检查 Celo 的可用性,这对你的 dApp 意味着什么?

Celo 的可用性涵盖网络健康状况和你的 dApp 所依赖的 RPC 端点。本文解释了如何监控 Celo 主网状态、评估 RPC 提供商的可靠性,并在你的基础设施中构建弹性。...

网络 RPCAvalanche

Avalanche 节点 RPC:如何连接、配置和调试你的端点

了解 Avalanche 节点 RPC 的工作原理、公共端点与专用端点之间的区别,以及如何为 C-Chain、X-Chain 和 P-Chain 配置你的 dApp。本指南涵盖链设置、常见 JSON-RPC 方法以及生产工作负载的故障排除技巧。...

网络 RPCEfinity

Unichain 节点:它是什么以及如何连接

Unichain 是一个以太坊 Layer 2 网络,旨在降低 DeFi 应用的延迟和成本。本文解释了什么是 Unichain 节点,如何通过 RPC 端点连接到网络,以及如何为你的项目选择公共、托管和专用节点选项。...

RPC 提供商选择Solana

哪些 Solana RPC 服务提供针对 NFT 和 DeFi 数据定制的增强 API?

大多数 Solana RPC 提供商都暴露相同的核心 JSON-RPC 接口,因此对于 NFT 和 DeFi 工作负载,真正的区别在于提供商处理代币账户、程序日志、压缩 NFT 和高容量 getProgramAccounts 调用的能力。增强 API 通常意味着在标准 RPC 之上叠加索引或专用方法...

永远不用担心基础设施

OnFinality 消除了 DevOps 的繁重工作,让您能够更聪明、更快地构建。

开始