BNB Smart Chain
eth_call
eth_call runs a contract function as a pure simulation against a chosen block's state. BNB Smart Chain, the BNB-native geth-equivalent EVM that hosts PancakeSwap and Venus, executes the bytecode locally and hands back the ABI-encoded output. Nothing is broadcast. No validator includes the call, and not a single wei of BNB leaves the caller's account. Send the request to https://bsc.therpc.io/YOUR_API_KEY at chain ID 56, and the result matches exactly what the contract would have produced on-chain.
Use cases
- Read BEP-20 token views such as
balanceOf,decimals,symbol, ortotalSupplyfor any token contract. - Query PancakeSwap pair
getReservesor quote a spot price directly from a Venus market. - Simulate a pending swap or transfer first, catching a revert before you sign and pay BNB gas.
- Apply state overrides to model what-if scenarios (a richer balance, swapped-in bytecode) without touching live chain state.
Parameters
| # | Name | Type | Required | Description |
|---|---|---|---|---|
| 1 | transaction | object | Yes | Transaction object. Required fields: `to` (target contract). Optional: `from` (msg.sender), `gas` (hex), `gasPrice` (hex), `value` (hex wei), `data` (ABI-encoded calldata). |
| 2 | blockTag | string | object | Yes | Block at which to execute the call. Use hex block number or a named tag.Default: latest |
| 3 | stateOverrides | object | No | Optional map of address → { balance, nonce, code, state, stateDiff } overrides applied only for this call. Not supported by all providers. |
Response
| Type | Description |
|---|---|
| string | Hex-encoded return data from the executed function. Decode with the contract ABI. If the call reverts, an error with code -32000 or 3 is returned instead. |
Example request
Try it live in the BNB Smart Chain playground.
Errors & troubleshooting
| Code | Message | Cause |
|---|---|---|
3 | execution reverted | The EVM reverted the call. Error data contains the revert reason. |
-32602 | invalid argument | Malformed transaction object or missing required `to` field. |
-32000 | execution reverted | Node-level revert without revert data (e.g. out-of-gas within the call, or require with no message). |
Common pitfalls
- A result read at
latestreflects that instant only. With ~3s BSC blocks, state can shift before your transaction is mined, so treat the value as advisory rather than a promise. - The third state-overrides argument is not honored by every BSC node. Code defensively and fall back to a plain call when overrides get rejected.
- A reverting contract surfaces as a JSON-RPC error (code 3 or -32000), never as a normal return value. Always handle the error branch explicitly.
Supported networks
- Mainnet — Chain ID: 56
- Testnet — Chain ID: 97
See also
Parameters
Transaction object. Required fields: `to` (target contract). Optional: `from` (msg.sender), `gas` (hex), `gasPrice` (hex), `value` (hex wei), `data` (ABI-encoded calldata).
"latest" | "safe" | "finalized" | "earliest" | "pending" | hex block number
Optional map of address → { balance, nonce, code, state, stateDiff } overrides applied only for this call. Not supported by all providers.