BNB Smart Chain

BNB Smart Chain

eth_chainId

eth_chainId returns the EIP-155 identifier of whatever network an endpoint serves. BNB Smart Chain runs PoSA consensus and settles fees in BNB, and it answers this call with "0x38", decimal 56, for mainnet. The Chapel testnet replies "0x61" (decimal 97). Query https://bsc.therpc.io/YOUR_API_KEY to read it. That same number is folded into every signed BSC transaction, binding it to one network so it cannot be replayed across chains.

Use cases

  • Pre-flight check before signing: confirm the wallet sits on 0x38 so a BSC transaction is not accidentally built for another EVM network.
  • Pair it with eth_blockNumber for a combined "alive and serving chain 56" health probe.
  • Pick the right deployment address when the same dApp ships on BSC, mainnet 56 versus Chapel testnet 97.
  • Bake the returned ID into the EIP-155 signature so a signed BNB transfer cannot be replayed onto a different chain.

Parameters

This method takes no parameters. Pass an empty array [].

Response

TypeDescription
string (hex)Hex-encoded chain ID integer (e.g. "0x1" for Ethereum mainnet).

Example request

curl https://bsc.therpc.io/YOUR_API_KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_chainId",
"params": [],
"id": 1
}'

Try it live in the BNB Smart Chain playground.

Errors & troubleshooting

CodeMessageCause
-32603Internal errorNode failed to retrieve chain configuration.

Common pitfalls

  • Do not treat this as interchangeable with net_version; on BSC the network ID happens to match, but the two RPCs are conceptually distinct and can diverge on other networks.
  • The answer is hex ("0x38"), so compare via BigInt(result) === 56n rather than string equality to dodge leading-zero and case mismatches.

Supported networks

  • Mainnet — Chain ID: 56
  • Testnet — Chain ID: 97

See also

curl https://bsc.therpc.io/YOUR_API_KEY \
-X POST \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":1,"method":"eth_chainId","params":[]}'

Ready to call this in production?

Free tier covers personal projects. Pay-as-you-go scales without a card.