eth_chainId
BNB Smart Chain / https://triport.io/rpc/bsc
Minimum tier: Free
Last updated:
eth_chainId returns the EVM chain identifier of BNB Smart Chain as a hex quantity.
Use it to verify that a client is connected to the intended chain before signing, displaying, or interpreting chain-specific data. The example result 0x38 is decimal 56, the BNB Smart Chain mainnet chain ID.
This differs from net_version, which returns the network identifier as a decimal string. Applications should generally use eth_chainId for EIP-155 chain selection.
Parameters
This method takes no parameters.
Returns
| Field | Type |
|---|---|
| chainId | Quantity |
Examples
curl https://triport.io/rpc/bsc \
-X POST -H 'Content-Type: application/json' \
-H 'Authorization: Bearer <api-key>' \
-d '{"jsonrpc":"2.0","id":1,"method":"eth_chainId","params":[]}'const res = await fetch("https://triport.io/rpc/bsc", {
method: "POST",
headers: { "Content-Type": "application/json", Authorization: "Bearer <api-key>" },
body: JSON.stringify({
"jsonrpc": "2.0",
"id": 1,
"method": "eth_chainId",
"params": []
}),
});
const data = await res.json();import requests
resp = requests.post(
"https://triport.io/rpc/bsc",
headers={"Authorization": "Bearer <api-key>"},
json={"jsonrpc":"2.0","id":1,"method":"eth_chainId","params":[]},
)
print(resp.json())Usage
- Transport: HTTP (JSON-RPC).
- Chain: BNB Smart Chain.
- Clusters: mainnet.
- Credit cost: 1 per call.
FAQ
- What does eth_chainId do?
- Return the chain identifier.
- How many credits does eth_chainId cost?
- eth_chainId costs 1 credit(s) per call on Triport by default.
- Is eth_chainId available over WebSocket?
- eth_chainId is an HTTP JSON-RPC method.