debug_traceTransaction
The debug_traceTransaction method returns the full trace of a transaction that has already been executed and included in a block. This method provides comprehensive debugging information including all internal calls, opcode execution, gas consumption at each step, and storage modifications.
This method is essential for post-mortem analysis of transactions, identifying bugs in smart contracts, and understanding complex transaction flows involving multiple contract interactions. Developers can use it to debug failed transactions, optimize gas usage, analyze reentrancy patterns, trace internal function calls, and understand exactly how a transaction executed at the EVM level. The configurable tracer options allow focusing on specific aspects of execution while minimizing overhead.
This method is available only on the full archive node.
Parameters
parameter | type | description |
|---|---|---|
transactionHash | string (required) | The hash of the transaction to trace (32-byte hex string with 0x prefix) |
traceConfig | object (optional) | Configuration object to customize the trace output |
Trace Config Properties:
property | type | description |
|---|---|---|
tracer | string (optional) | The type of tracer: 'callTracer' for call tree, 'prestateTracer' for state diff, '4byteTracer' for method signatures, or custom JavaScript tracer code |
timeout | string (optional) | Maximum time allowed for the trace operation (e.g., '10s'). Defaults to '5s' |
disableStorage | boolean (optional) | Set to true to disable storage capture, significantly reducing trace size and improving performance |
disableMemory | boolean (optional) | Set to true to disable memory capture in the trace |
disableStack | boolean (optional) | Set to true to disable stack capture in the trace |
enableMemory | boolean (optional) | Set to true to enable memory capture (opposite of disableMemory) |
enableReturnData | boolean (optional) | Set to true to enable capturing return data from calls |
Return Object
The method returns detailed trace information with structure depending on the tracer used:
With default tracer:
- gas -
number: Total gas used by the transaction - failed -
boolean: Whether the transaction failed - returnValue -
string: The return data from the transaction execution - structLogs -
array: Array of opcode execution steps, where each step contains:- pc -
number: Program counter position - op -
string: Opcode name (PUSH1, ADD, SSTORE, etc.) - gas -
number: Remaining gas before executing this opcode - gasCost -
number: Gas cost of this opcode - depth -
number: Call depth (1 for main call, increases for internal calls) - stack -
array: The EVM stack state (if not disabled) - memory -
array: The memory state (if enabled) - storage -
object: Storage changes (if not disabled)
- pc -
With callTracer:
- type -
string: The type of the call (CALL, CREATE, DELEGATECALL, STATICCALL, etc.) - from -
string: The address initiating the call - to -
string: The address receiving the call - value -
string: The value transferred in wei (hex) - gas -
string: The gas provided for the call (hex) - gasUsed -
string: The gas actually consumed (hex) - input -
string: The input data sent with the call - output -
string: The output data returned from the call - error -
string: Error message if the call failed - calls -
array: Array of nested internal calls made during execution, each with the same structure
Request Example
Response Example