debug_traceTransaction - BSC RPC Method
Trace a transaction execution on Binance Smart Chain. Works on full nodes for retained recent state; older historical state requires a dedicated archive node or cluster.
Traces a transaction execution on Binance Smart Chain by transaction hash.
Node Requirement
BSC API endpoints are full nodes with debug APIs enabled. Debug methods work for blocks and transactions whose state is still retained on the node. Older historical state requires an archive node, available as a dedicated node or dedicated cluster.
When to Use This Method
- Analyze transaction execution step-by-step - Trace every opcode and internal call in a completed transaction for high-frequency DeFi (PancakeSwap), NFT marketplaces, and GameFi applications
- Debug failed transactions - Pinpoint the exact opcode and call depth where a transaction reverted on BSC
- Examine internal call traces - Follow the full call tree including delegate calls and contract creations
- Gas usage profiling - Measure gas consumption per opcode to identify optimization opportunities
Best Practices
- Requires archive node access; not available on standard full nodes
- Traces can be very large for complex transactions with many internal calls
- Use tracer options like
onlyTopCallorcallTracerto limit output size - Store traces off-chain for analysis rather than querying repeatedly
Tracer Options
{}- Default opcode tracer (verbose){ tracer: "callTracer" }- Call tree tracer{ tracer: "prestateTracer" }- Pre-state tracer
Code Examples
Related Methods
debug_traceCall- Trace without executingdebug_traceBlockByNumber- Trace entire block