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
0x38so a BSC transaction is not accidentally built for another EVM network. - Pair it with
eth_blockNumberfor 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
| Type | Description |
|---|---|
| string (hex) | Hex-encoded chain ID integer (e.g. "0x1" for Ethereum mainnet). |
Example request
Try it live in the BNB Smart Chain playground.
Errors & troubleshooting
| Code | Message | Cause |
|---|---|---|
-32603 | Internal error | Node 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 viaBigInt(result) === 56nrather than string equality to dodge leading-zero and case mismatches.
Supported networks
- Mainnet — Chain ID: 56
- Testnet — Chain ID: 97