BNB Smart Chain

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, or totalSupply for any token contract.
  • Query PancakeSwap pair getReserves or 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

#NameTypeRequiredDescription
1transactionobjectYesTransaction object. Required fields: `to` (target contract). Optional: `from` (msg.sender), `gas` (hex), `gasPrice` (hex), `value` (hex wei), `data` (ABI-encoded calldata).
2blockTagstring | objectYesBlock at which to execute the call. Use hex block number or a named tag.Default: latest
3stateOverridesobjectNoOptional map of address → { balance, nonce, code, state, stateDiff } overrides applied only for this call. Not supported by all providers.

Response

TypeDescription
stringHex-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

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

Try it live in the BNB Smart Chain playground.

Errors & troubleshooting

CodeMessageCause
3execution revertedThe EVM reverted the call. Error data contains the revert reason.
-32602invalid argumentMalformed transaction object or missing required `to` field.
-32000execution revertedNode-level revert without revert data (e.g. out-of-gas within the call, or require with no message).

Common pitfalls

  • A result read at latest reflects 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.

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

Ready to call this in production?

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