BNB Smart Chain

BNB Smart Chain

trace_call

trace_call runs a call against a chosen block's state and traces it, without ever broadcasting a transaction. The result can include an OpenEthereum-style call-tree trace, an optional opcode-level VM trace, and an optional state diff. BSC settles in BNB and runs the BEP-20 contracts behind venues like PancakeSwap, so this is how you preview what a router or swap call would actually do before committing gas to it. Send the request to chain ID 56 at https://bsc.therpc.io/YOUR_API_KEY. The traceTypes array decides which artifacts get computed, keeping the response to the detail you asked for. Simulating against a past block pulls in historical state, which makes it a heavy call that needs a trace-enabled archive node.

Use cases

  • Map the full call tree a transaction would spawn before you broadcast it.
  • Ask for stateDiff to confirm a prospective transaction touches exactly the balances and storage slots you expect, and nothing more.
  • Test contract logic against a historical BSC block state, which calls for a trace-enabled archive node.

Parameters

#NameTypeRequiredDescription
1transactionobjectYesCall object: `from?`, `to`, `gas?`, `gasPrice?`, `value?`, `data?`.
2traceTypesarrayYesArray of trace types to include: `"trace"` (call tree), `"vmTrace"` (opcode-level), `"stateDiff"` (storage/balance diffs).
3blockParameterstringNoBlock state against which to simulate the call.Default: latest

Response

TypeDescription
object`{output, trace?, stateDiff?, vmTrace?}` — `trace` is a flat call-tree array, `stateDiff` maps each touched address to its balance/nonce/code/storage diffs, `vmTrace` provides opcode-level detail (Parity-format).

Example request

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

Try it live in the BNB Smart Chain playground.

Errors & troubleshooting

CodeMessageCause
-32601Method not foundtrace namespace not enabled or client does not support trace_call.
-32602Invalid paramsTransaction object missing required fields, traceTypes array is empty or contains unrecognized values, or blockParameter is invalid.
-32000execution revertedSimulated call reverted; partial trace is still returned.

Common pitfalls

  • Asking for trace, vmTrace, and stateDiff together can balloon the response, so request only the artifacts you actually need.
  • Historical block states require a node running the trace API over archive data, which lower tiers may not provide.
  • The vmTrace output uses a Parity-specific shape that differs from the structLog Geth returns from debug_traceCall.

Supported networks

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

See also

Parameters

Call object: `from?`, `to`, `gas?`, `gasPrice?`, `value?`, `data?`.

["trace"] | ["trace","vmTrace","stateDiff"] — at least one required

hex block number or "latest" | "earliest" | "pending"

curl https://bsc.therpc.io/YOUR_API_KEY \
-X POST \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":1,"method":"trace_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.