Logo
RPC Assistant

How do I set up a BNB testnet endpoint and debug my dApp?

摘要

BNB Testnet (chain ID 97) is an EVM-compatible test network for BNB Smart Chain. Developers use it to deploy and test smart contracts, dApps, and integrations without risking real funds. This guide covers RPC endpoints, faucet details, MetaMask configuration, and common debugging steps.

BNB Testnet is the official test environment for BNB Smart Chain (formerly BSC). It allows developers to deploy and interact with smart contracts, test dApp functionality, and validate integrations before moving to mainnet—all without spending real BNB. This reference covers the essential chain settings, RPC endpoints, faucet options, wallet configuration, and common pitfalls.

BNB Testnet Endpoint Decision Checklist

Before connecting your application to BNB Testnet, review these criteria to ensure the RPC endpoint you choose fits your development workflow.

CriterionWhat to checkWhy it matters
Rate limitsFree tier requests per second (e.g., public endpoint vs. API key)Public endpoints are often rate-limited; for automated CI/CD or load testing, a private endpoint is necessary.
WebSocket supportDoes the provider offer wss:// endpoint?Required for real-time event listening (e.g., contract event subscriptions).
Archive dataAccess to historical state from genesis?Needed for backtesting, analytics, or dApps that query past balances.
Geographic latencyServer locations relative to your team or usersHigher latency increases transaction broadcast time and block retrieval.
FailoverDoes the provider have multiple nodes?Single-node endpoints risk downtime; a robust provider offers automatic failover.
Faucet integrationCan you request tBNB easily?Without test tokens, you cannot deploy contracts or send transactions.

What Is BNB Testnet?

BNB Testnet is a feature-complete replica of BNB Smart Chain (BSC) mainnet. It uses the same Proof-of-Staked-Authority (PoSA) consensus, identical EVM opcodes, and fast block times (~3 seconds). The native test token is tBNB, which has no real monetary value. Developers use BNB Testnet for:

  • Smart contract deployment and unit testing
  • Integration testing with wallets, oracles, and bridges
  • Performance and load testing of dApps
  • CI/CD pipeline verification before mainnet releases

Chain Settings and RPC Endpoints

To connect to BNB Testnet, you need the following chain parameters:

  • Chain ID: 97
  • Network Name: BNB Smart Chain Testnet (or BSC Testnet)
  • Currency Symbol: tBNB
  • Block Explorer: https://testnet.bscscan.com

RPC Endpoints

ProviderHTTP EndpointWebSocket EndpointType
OnFinality (public)https://bnb-testnet.api.onfinality.io/publicwss://bnb-testnet.api.onfinality.io/public-wsPublic (rate-limited)
OnFinality (API key)https://bnb-testnet.api.onfinality.iowss://bnb-testnet.api.onfinality.io/wsPrivate (higher limits)
Chain officialhttps://data-seed-prebsc-1-s1.bnbchain.org:8545wss://data-seed-prebsc-1-s1.bnbchain.org:8546Public (rate-limited)

To test your connection, use a simple curl call:

curl -H 'content-type:application/json' -d '{"id": 1, "jsonrpc": "2.0", "method": "eth_blockNumber"}' 'https://bnb-testnet.api.onfinality.io/public'

If successful, you receive a response like {"jsonrpc":"2.0","id":1,"result":"0x6f8b3c"}.

For production testing workflows, sign up for a free OnFinality account to obtain an API key with higher rate limits and access to archival and trace data.

Getting Test Tokens (Faucet)

Deploying contracts and sending transactions on BNB Testnet requires tBNB. The official BNB Chain Testnet Faucet provides 0.3 tBNB per request (once every 24 hours). Alternative faucets include:

  • Thirdweb Faucet: Offers 0.01 tBNB/day with wallet connection.
  • QuickNode Faucet: Requires a QuickNode account but provides larger amounts.
  • Chainstack Faucet: Similar to QuickNode, often requires an account.

Tip: If you need more than 0.3 tBNB for extensive testing, combine multiple faucets or contact the BNB Chain team through their official Discord.

Adding BNB Testnet to MetaMask

To use BNB Testnet with MetaMask or other EVM wallets:

  1. Open MetaMask and click the network dropdown at the top.
  2. Select "Add network" (or "Custom network" in older versions).
  3. Fill in the details:
    • Network Name: BNB Smart Chain Testnet
    • New RPC URL: https://bnb-testnet.api.onfinality.io (or your preferred endpoint)
    • Chain ID: 97
    • Currency Symbol: tBNB
    • Block Explorer URL: https://testnet.bscscan.com
  4. Click "Save".

After adding, switch to BNB Testnet and request tBNB from a faucet. You can then deploy contracts using Hardhat, Truffle, or Foundry.

Common Issues and Debugging

Transaction Stuck / Pending

  • Cause: Low gas price or nonce mismatch.
  • Fix: Increase gas price or reset nonce in MetaMask (Settings > Advanced > Clear activity tab data).

"Method not found" Errors

  • Cause: Using a mainnet-only method like eth_call with state override (not a testnet issue).
  • Fix: Verify the method is supported on testnet. For eth_call, ensure the block parameter is valid.

Connection Timeout

  • Cause: The RPC endpoint is unreachable or rate-limited.
  • Fix: Switch to a different endpoint or switch to a private API key. Check provider status pages.

Insufficient Funds for Deployment

  • Cause: Wallet has 0 tBNB.
  • Fix: Use faucet to request test tokens. If faucet returns an error, try a different faucet or wait 24 hours.

Chain ID Mismatch

  • Cause: Wallet connected to a different network (e.g., mainnet).
  • Fix: Switch to BNB Testnet in your wallet. Verify the chain ID in your dApp configuration.

Key Takeaways

  • BNB Testnet (chain ID 97) is an essential tool for testing BSC dApps before mainnet deployment.
  • Use a reliable RPC provider—especially for automated testing—to avoid rate limits and downtime. OnFinality offers both public and private endpoints with WebSocket support.
  • Always check that your wallet and application use the correct chain ID and RPC URL.
  • Faucets are the only way to obtain tBNB; plan your testing to avoid running out.
  • Archive nodes are available for historical data queries; confirm your provider supports them.

Frequently Asked Questions

Q: What is the difference between BNB Testnet and opBNB Testnet? A: BNB Testnet is for BNB Smart Chain (EVM), while opBNB Testnet is an Optimistic rollup testnet. Both are part of the BNB ecosystem but serve different purposes.

Q: Can I use BNB Testnet on hardware wallets? A: Yes, you can configure a hardware wallet (e.g., Ledger) with MetaMask to interact with BNB Testnet, but ensure the device is not set to mainnet.

Q: How fast are blocks on BNB Testnet? A: Approximately 3 seconds, same as mainnet. This allows quick testing iterations.

Q: Is there a testnet explorer? A: Yes, testnet.bscscan.com provides transaction and block details.

Q: Can I deploy a mainnet contract to testnet? A: Yes, because both environments are EVM-compatible. Deploy the same bytecode to testnet first to verify behavior.

For further help, explore the full list of supported networks on OnFinality or check our pricing page for production-grade plans.

RPC 知识库

相关 RPC 内容

Network Rpc

选择 HyperEVM RPC 提供商时应注意什么?

# 选择 HyperEVM RPC 提供商时应注意什么? HyperEVM RPC 提供商之所以重要,是因为 Web3 应用依赖稳定的端点访问来进行读取、交易、仪表盘和后端工作流。正确的设置应匹配你的工作负载,支持你所需的网络和测试网,使限制可见,并在共享 RPC 不再足够时提供扩展路径。 对于 H...

Rpc Provider Selection

Web3行业中领先的以太坊RPC解决方案有哪些?

# Web3行业中领先的以太坊RPC解决方案有哪些? 以太坊仍然是去中心化金融、NFT以及不断增长的L2 Rollup生态系统的基石。每天超过170万笔交易和550亿美元的TVL,使得RPC基础设施的选择直接影响应用的可靠性、延迟和成本。Web3行业中领先的以太坊RPC解决方案包括Alchemy、I...

Network Rpc

什么是 TON RPC,如何使用它?

# 什么是 TON RPC,如何使用它? TON(The Open Network)是一个为高可扩展性和与 Telegram 深度集成而设计的 layer-1 区块链。与 EVM 链不同,TON 采用独特的分片和异步智能合约架构。要从 Web 应用程序与 TON 交互,需要一个 RPC(远程过程调用...

Network Rpc

Polkadot Asset Hub 迁移:开发者中继链过渡指南

# Polkadot Asset Hub 迁移:开发者中继链过渡指南 Polkadot Asset Hub 迁移于 2025 年 11 月 4 日执行,将核心面向用户的功能——余额、质押、治理——从中继链迁移到 Asset Hub 系统平行链。这一架构转变减少了中继链的膨胀,实现了更快的升级,并为 ...

Rpc Provider Selection

如何为生产应用选择Polygon RPC提供商

选择Polygon RPC提供商对于依赖Polygon PoS链可靠访问的dApp、DeFi协议和基础设施至关重要。本指南涵盖评估标准——包括速率限制、存档数据支持和专用节点选项——并提供决策框架,帮助您将提供商与工作负载匹配。...

Rpc Provider Selection

2026年最新网络升级的最佳以太坊RPC是什么?

以太坊的快速演进——从Dencun(EIP-4844 blob)到未来的Pectra和Verkle升级——要求RPC提供商跟上协议变化的步伐。最佳以太坊RPC应能立即支持新的JSON-RPC方法、更新的状态格式,并在硬分叉期间保持向后兼容。本指南将说明如何评估提供商的升级就绪性。...

永远不用担心基础设施

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

开始