← Protocols
BNB Chain
01Description

BNB Chain is a Binance-affiliated EVM-compatible ecosystem comprising BNB Smart Chain (BSC, chain id 56) — a PoSA L1 — and opBNB, an OP-Stack L2 (chain id 204) that settles to BSC. Both chains are fully EVM-compatible so viem, ethers, wagmi, and Foundry/Hardhat work unchanged; the bnb-chain GitHub org publishes the `bsc` and `opbnb` execution clients as well as Greenfield, BNB Chain's decentralized storage layer.

02Best for
  • 01EVM dapps targeting BSC and opBNB
  • 02PancakeSwap, Venus, and BNB-native DeFi integrations
  • 03low-fee L2 deployments on opBNB
  • 04BNB Greenfield decentralized storage
  • 05cross-deploying Ethereum contracts to BNB Chain with no Solidity changes
03Install
  • pnpm add viem wagmi @rainbow-me/rainbowkit
04Environment variables
VariableScopeDescription
NEXT_PUBLIC_BSC_RPC_URLClientBNB Smart Chain JSON-RPC URL (e.g. https://bsc-dataseed.bnbchain.org or a paid Ankr/QuickNode/NodeReal endpoint). Public dataseeds are heavily rate-limited.
NEXT_PUBLIC_OPBNB_RPC_URLClientopBNB JSON-RPC URL (e.g. https://opbnb-mainnet-rpc.bnbchain.org).
BSCSCAN_API_KEYServerBscScan API key for contract verification and tx queries. Server-side only.
05Prompt snippet
BNB Chain is fully EVM-compatible — use viem/wagmi as you would for Ethereum. Configure the chains: `import { bsc, opBNB } from 'viem/chains'; const client = createPublicClient({ chain: bsc, transport: http(process.env.NEXT_PUBLIC_BSC_RPC_URL) });`. For wallet auth wire wagmi: `createConfig({ chains: [bsc, opBNB], transports: { [bsc.id]: http(...), [opBNB.id]: http(...) } })`. Deploy contracts with Foundry/Hardhat unchanged — `forge create --rpc-url $BSC_RPC_URL --private-key $PK src/Token.sol:Token`. For opBNB you also need an L1->L2 bridge step using the standard OP Stack bridge contracts. To use Greenfield storage, install `@bnb-chain/greenfield-js-sdk` and call `client.object.createObject({ bucketName, objectName, body })`.
06Gotchas
  • BSC has 3-second block times and uses PoSA (Proof-of-Staked-Authority) with 21 active validators — finality is probabilistic and reorgs of 1–2 blocks happen; wait at least 15 confirmations for high-value txs (BSC docs recommend 15).
  • BSC chain id is 56 (mainnet) / 97 (testnet); opBNB is 204 / 5611. Mixing chain IDs in EIP-155 signatures yields silent `nonce too low` or replay-protection rejections.
  • Public RPC endpoints (`bsc-dataseed*.binance.org`, now `*.bnbchain.org`) are aggressively rate-limited and inconsistent across nodes — use a paid provider (NodeReal, Ankr, QuickNode, GetBlock) for production. The legacy `binance.org` URLs still resolve but are deprecated in favor of `bnbchain.org`.
  • opBNB is OP Stack but its sequencer is run by BNB Chain — withdrawals to BSC require the standard ~7-day fault-proof window; users expecting instant L2->L1 withdrawals will be confused.
  • BNB token has two forms: BEP-20 (BSC native) and BEP-2 (legacy Beacon Chain, now sunsetted as a separate chain). Bridging between them via Binance Bridge is no longer supported — Beacon Chain was fused into BSC in 2024.
  • Gas is paid in BNB. The `gasPrice` floor is enforced at ~3 gwei on BSC and ~0.001 gwei on opBNB; legacy txs work but EIP-1559 (`maxFeePerGas`/`maxPriorityFeePerGas`) is supported and recommended on both chains.
  • Contract verification on BscScan / opBNBScan requires the exact compiler version and optimization settings. `forge verify-contract` works with `--verifier-url` set to the BscScan API endpoint.
07Alternatives