The debug_traceTransaction
method recreates the exact execution state of a historical transaction, providing detailed opcode-level trace information. It reproduces the original state at the specific block where the transaction was executed, allowing for complete analysis of transaction execution flow, stack operations, memory changes, storage modifications, and gas consumption.
Unlike other transaction retrieval methods that only provide basic transaction data, debug_traceTransaction
offers introspection into the internal execution of the EVM during transaction processing.
This method traces the transaction identified by its hash, providing opcode-level execution details.
Hash of the transaction to trace
Trace options
Setting this to true disables storage capture
Setting this to true disables memory capture
Setting this to true disables stack capture
Use a custom tracer (available: callTracer, prestateTracer, etc.)
Overrides the default timeout of 5 seconds for JavaScript-based tracing
The trace result with execution details
Gas used by the transaction
Whether the transaction failed
The return value of the transaction
Array of structured EVM operation logs
Program counter position
The executed opcode
Remaining gas
Gas cost for this operation
Call depth
EVM memory contents (if not disabled)
EVM stack contents (if not disabled)
Storage changes (if not disabled)
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"gas": 21000,
"failed": false,
"returnValue": "",
"structLogs": [
{
"pc": 0,
"op": "PUSH1",
"gas": 4677951,
"gasCost": 3,
"depth": 1,
"stack": [],
"memory": [],
"storage": {}
},
{
"pc": 2,
"op": "MSTORE",
"gas": 4677948,
"gasCost": 12,
"depth": 1,
"stack": ["0x60", "0x40"],
"memory": [
"0000000000000000000000000000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000000000000000000000000000"
],
"storage": {}
}
// Many more opcode logs...
]
}
}
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"from": "0x8894e0a0c962cb723c1976a4421c95949be2d4e3",
"gas": "0x2d48c",
"gasUsed": "0x594c",
"to": "0x55d398326f99059ff775485246999027b3197955",
"input": "0xa9059cbb000000000000000000000000b5cfcb4b073ebcda22f57097dbd0e0be5731ca5c00000000000000000000000000000000000000000000000011c37937e08000",
"output": "0x0000000000000000000000000000000000000000000000000000000000000001",
"calls": [
{
"type": "CALL",
"from": "0x55d398326f99059ff775485246999027b3197955",
"to": "0xb5cfcb4b073ebcda22f57097dbd0e0be5731ca5c",
"gas": "0x1e25b",
"gasUsed": "0x30b",
"input": "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"output": "0x"
}
],
"value": "0x0"
}
}
You can tune performance and output by configuring these options:
--http.api=debug
flag)debug_traceTransaction
provides more detailed information than trace_transaction
BLOCKHASH
have their results from the original execution cached and reused