Summary
Binance Smart Chain, now officially BNB Smart Chain (BSC), is an EVM-compatible layer-1 blockchain with 3-second block times, mainnet chain ID 56, and testnet chain ID 97. Solidity developers can reuse Ethereum tooling—Hardhat, Foundry, OpenZeppelin, ethers.js, and web3.js—with minimal configuration changes. You need a reliable RPC endpoint: OnFinality provides EVM-compatible HTTPS and WebSocket RPC endpoints, Archive support, and trace/API access at https://bnb.api.onfinality.io/public for mainnet and https://bnb-testnet.api.onfinality.io/public for testnet. For testnet development use chain ID 97 and obtain tBNB from a faucet; for mainnet use chain ID 56 and BNB for gas. Deployment follows standard EVM flow: compile, test, estimate gas, send signed transaction, monitor receipt, and verify on BscScan. Handle nonces sequentially to avoid stuck or rejected transactions. Use testnet-to-mainnet promotion with security checks, secret management, contract verification, and rollback readiness. This guide covers Solidity tooling, chain configuration, contract deployment, finality, nonce/gas handling, RPC error diagnosis, and pre-mainnet operational checklists.
Key Takeaways
- BNB Smart Chain (BSC) is EVM-compatible with chain ID 56 mainnet / 97 testnet; reuse Ethereum Solidity tools.
- Use reliable RPC endpoints like OnFinality's HTTPS/WebSocket endpoints; beware official public endpoints' rate limits and eth_getLogs deactivation.
- Handle nonces sequentially and estimate gas with buffer to avoid stuck deployments.
- Promote from testnet only after security checks, contract verification, secret hygiene, and rollback readiness.
BNB Smart Chain (BSC) Terminology and Network Basics
Binance Smart Chain (BSC) is the legacy name for what is now officially BNB Smart Chain. BSC remains widely used in wallets, tooling, and older documentation. The network is EVM-compatible and uses Proof of Staked Authority (PoSA) with 21 validators, producing blocks approximately every 3 seconds.
Do not confuse BNB Smart Chain with BNB Greenfield (data storage) or opBNB (Layer 2). Mainnet uses chain ID 56 (0x38) and BNB as the native gas token. Testnet uses chain ID 97 (0x61) and tBNB. For network details, see /networks/bnb.
- Mainnet: chain ID 56 / 0x38, currency BNB, block time ~3s
- Testnet: chain ID 97 / 0x61, currency tBNB
- PoSA consensus with 21 validators
Solidity Development with Hardhat: Project Setup, Testing, and Deployment Scripts
Hardhat is the most common Solidity workflow for BNB Smart Chain because it mirrors Ethereum tooling. Initialize a project, install the Hardhat toolbox, and configure BSC networks with your RPC endpoints.
Keep private keys out of hardhat.config.js and repository files. Load them from process.env or a secrets manager.
- Run
npx hardhat initandnpm install --save-dev @nomicfoundation/hardhat-toolbox - Organize contracts under contracts/, tests under test/, and deployment scripts under scripts/
- Use
npx hardhat testfor local tests andnpx hardhat run scripts/deploy.js --network bscTestnetfor testnet deployment
Solidity Development with Foundry
Foundry is a fast, Rust-based alternative for BNB Smart Chain development. It includes forge for building and testing and cast for RPC interaction.
Create a Foundry project with forge init, then run forge test. For deployment, use forge create --rpc-url https://bnb-testnet.api.onfinality.io/public --private-key $PRIVATE_KEY src/MyContract.sol:MyContract.
- Use
forge buildfor compilation with optimizations in foundry.toml - Use
cast callandcast sendfor manual RPC debugging - Foundry supports BSC chain IDs through standard --rpc-url and --chain options
RPC Endpoint and Chain Settings for BNB Smart Chain
OnFinality provides EVM-compatible HTTPS and WebSocket RPC endpoints, Archive support, and trace/API access for BNB mainnet and testnet. Public mainnet endpoint: https://bnb.api.onfinality.io/public. Public testnet endpoint: https://bnb-testnet.api.onfinality.io/public.
For wallet or tool configuration, set Chain ID 56 and BNB symbol for mainnet; Chain ID 97 and tBNB for testnet. The official BNB Chain documentation also lists public endpoints such as https://bsc-dataseed.bnbchain.org (mainnet) and https://bsc-testnet-dataseed.bnbchain.org (testnet). Those official public list endpoints have a rate limit of 10K requests per 5 minutes and eth_getLogs is disabled on the listed mainnet endpoints. These limitations apply to the official public list, not necessarily to OnFinality endpoints. Always verify supported methods in the BSC API reference at /rpc-assistant/bsc-api.
See /rpc-assistant/bnb-smart-chain-endpoint for complete chain settings and endpoint details.
- Mainnet RPC: https://bnb.api.onfinality.io/public (HTTPS/WebSocket, Archive, trace/API)
- Testnet RPC: https://bnb-testnet.api.onfinality.io/public
- Never send mainnet BNB to testnet addresses or use mainnet chain ID for testnet
Contract Deployment, Finality, Nonce, and Gas Handling
Deployment on BNB Smart Chain uses standard EVM transaction flow: compile, test, estimate gas, populate nonce, sign, broadcast, then wait for receipt. Use eth_estimateGas before sending to catch out-of-gas errors. Set a gas limit with approximately 20-30% buffer above the estimate.
Nonce handling is critical. BSC uses sequential nonces. If you send multiple transactions from one address, ensure each transaction uses the next nonce. A 'nonce too low' error means you reused a nonce; 'nonce too high' means you skipped one. Use eth_getTransactionCount(address, 'pending') to fetch the next nonce before signing.
BSC has a dual-layer finality mechanism. The official BSC API includes eth_getFinalizedHeader and eth_getFinalizedBlock for economic finality, plus eth_health and other methods. These are not standard EVM methods; they require a provider that supports them. Refer to /rpc-assistant/bsc-api for the full method list. For probabilistic finality, wait for several block confirmations before treating a transaction as settled.
- Use pending nonce to avoid collisions
- Estimate gas and add buffer
- For high-value transactions, wait for economic finality if supported, otherwise use >=5 block confirmations
RPC Error Diagnosis for BNB Smart Chain
Most RPC errors fall into a few categories. Read the JSON-RPC error object and compare against the common causes below. For production, prefer a dedicated BSC RPC endpoint and monitor error rates. Evaluation criteria are covered in /rpc-assistant/bnb-chain-rpc-provider.
| Criterion | What to check | Why it matters |
|---|---|---|
| rate limit exceeded | Endpoint quota reached or public limit hit | Indicates need for dedicated endpoint or reduced polling |
| method not found | Method is not supported by the node | Use standard EVM methods or BSC-specific methods listed in /rpc-assistant/bsc-api |
| block not found | Node out of sync or pruned state | Use a synced provider or Archive endpoint for historical queries |
| nonce too low | Transaction nonce reused | Fetch pending nonce before signing |
| nonce too high | Skipped a nonce | Wait for previous nonce to mine or resubmit with next nonce |
| insufficient funds | Balance too low for gas + value | Fund account with BNB/tBNB or lower gas price |
| gas required exceeds allowance | Gas limit too low for transaction | Increase gasLimit based on eth_estimateGas |
Testnet-to-Mainnet Promotion, Security, Secrets, Verification, and Rollback Readiness
Deploy and test on BNB Smart Chain testnet first. Obtain tBNB from a faucet, run your test suite against testnet, and verify contract source on the testnet explorer. Then repeat on mainnet only after all checks pass.
Secrets never belong in code or client-side bundles. Use environment variables, secret managers, or hardware wallets for deployment keys. For deployment scripts, load private keys from process.env and restrict access to CI variables.
Verify contracts on BscScan using Hardhat's verify plugin or Foundry's verify-contract. Verification helps users and auditors confirm source code matches deployed bytecode.
Keep rollback readiness: use upgradeable contracts or pausable patterns, maintain a multisig for admin functions, and set up monitoring/alerting for failed transactions or unusual states. Test rollback paths on testnet before mainnet.
For testnet setup and faucet steps, see /rpc-assistant/bnb-smart-chain-testnet-guide.
- Deploy to BSC testnet chain ID 97 first
- Store secrets only in environment variables or secret managers
- Verify source on BscScan after every environment
- Implement pause/upgrade or multisig before mainnet
Pre-Mainnet Deployment Checklist for BNB Smart Chain
Use this operational checklist before promoting any contract to BSC mainnet. If any item fails, resolve it before mainnet deployment.
| Criterion | What to check | Why it matters |
|---|---|---|
| Compilation | Contract compiles with same optimizer settings | Avoid bytecode differences between testnet and mainnet |
| Tests | Unit and integration tests pass on testnet | Catch logic errors before value is at risk |
| Testnet verification | Verified on testnet explorer | Confirms source matches deployed bytecode |
| Security review | Audit or peer review complete | Reduces risk of exploits and user loss |
| Nonce strategy | Use pending nonces and sequential sending | Prevents stuck or invalid transactions |
| Gas configuration | Estimate gas and set buffer | Avoid out-of-gas and underpriced replacements |
| RPC endpoint reliability | HTTPS/WebSocket, Archive if needed, trace if debug | Production uptime and data availability |
| Secrets management | No private keys in repo or logs | Prevents key leakage |
| Monitoring & rollback | Alerts, pause/upgrade path, multisig | Enables incident response |
Frequently Asked Questions
What is the difference between Binance Smart Chain, BNB Smart Chain, and BSC?
They refer to the same EVM-compatible blockchain. BNB Smart Chain is the current official name; BSC and Binance Smart Chain are legacy aliases still used by tooling and docs. BNB Chain is the broader ecosystem that also includes opBNB and BNB Greenfield.
Can I use Ethereum libraries like ethers.js, web3.js, Hardhat, and Foundry on BSC?
Yes. BSC is EVM-compatible, so standard Ethereum tooling works with only network configuration changes. Use chain ID 56 for mainnet and 97 for testnet.
How do I get tBNB for BSC testnet?
Use the official BNB Chain testnet faucet or community faucets. tBNB has no monetary value. See /rpc-assistant/bnb-smart-chain-testnet-guide for workflow.
What RPC endpoints does OnFinality provide for BNB Smart Chain?
OnFinality provides HTTPS and WebSocket RPC for mainnet at https://bnb.api.onfinality.io/public and testnet at https://bnb-testnet.api.onfinality.io/public, with Archive support and trace/API access. For network details see /networks/bnb.
What finality methods are available on BSC?
Official BSC API includes eth_getFinalizedHeader and eth_getFinalizedBlock for economic finality, plus eth_health and others. Not all providers expose them. For full list see /rpc-assistant/bsc-api.
How do I verify my contract on BscScan?
Use Hardhat verify plugin or Foundry verify-contract. You need the deployed address, constructor arguments, and exact compiler settings.