debug_traceTransaction
Executes the transaction identified by the given hash in the exact manner it was executed on the network, replaying all prior transactions in the same block as necessary to reconstruct the correct pre-execution state. When no tracer is specified (or the tracer field is absent), the opcode (struct) logger is used and the result conforms to OpcodeTransactionTrace. When the tracer field in TraceConfig is "callTracer", the result conforms to CallFrame: the transaction's call tree with one frame per call, create, or selfdestruct, configurable via CallTracerConfig in tracerConfig. For other named tracers (e.g. "prestateTracer"), the result contains tracer-specific output; defining the output schemas of other named tracers is outside the scope of this specification.
Replays a transaction and returns its trace.
Parameters (by position)
Transaction hash string required
TraceConfig object
Configuration object accepted by debug_traceBlockByNumber, debug_traceBlockByHash, debug_traceTransaction, and (extended as TraceCallConfig) debug_traceCall. When the tracer field is absent or empty, the opcode (struct) logger is used and the result conforms to OpcodeTransactionTrace. The fields enableMemory, disableStack, disableStorage, enableReturnData, and limit only apply to the opcode logger and are ignored when a named tracer is set. When the tracer field is "callTracer", the result conforms to CallFrame and tracerConfig accepts CallTracerConfig. For other named tracers (e.g. "prestateTracer"), the result format is tracer-specific; defining the output schemas of other named tracers is outside the scope of this specification.
Show TraceConfig object
TraceConfig objectTraceConfig fields
-
debug
booleanOpcode logger only. When true, the client may print the trace output to its internal log during execution. Has no effect on the JSON-RPC response. Ignored when tracer is set. Default: false.
-
disableStack
booleanOpcode logger only. Setting to true disables stack capture in structLogs. When true, the stack field is omitted from each StructLog entry. Ignored when tracer is set. Default: false.
-
disableStorage
booleanOpcode logger only. Setting to true disables storage capture in structLogs. When true, the storage field is omitted from each StructLog entry. Ignored when tracer is set. Default: false.
-
enableMemory
booleanOpcode logger only. Setting to true enables memory capture in structLogs. When false (default), the memory field is omitted from each StructLog entry. Ignored when tracer is set. Default: false.
-
enableReturnData
booleanOpcode logger only. Setting to true enables return data capture in structLogs. When false (default), the returnData field is omitted from each StructLog entry. Ignored when tracer is set. Default: false.
-
limit
integerOpcode logger only. Maximum number of opcode steps to capture. Zero means no limit. When the limit is reached, execution continues but no further StructLog entries are recorded. The limit counts StructLog entries. Clients MUST NOT apply it as a limit on the size of the output in bytes. Ignored when tracer is set. Default: 0 (unlimited).
Range:
>= 0
-
timeout
stringOptional duration string specifying a timeout for trace execution. Clients that do not support execution timeouts (e.g. streaming implementations) MAY ignore this field. When supported and the timeout is reached, the client MUST return an error; no partial results are returned. Accepts Go duration strings (e.g. "5s", "300ms", "2m").
-
tracer
stringThe name of a built-in or custom tracer to use. When absent or empty, the opcode (struct) logger is used. Example built-in tracer names in go-ethereum include: 4byteTracer, callTracer, prestateTracer, noopTracer, bigramTracer, evmdisTracer, opcountTracer, trigramTracer, unigramTracer. Clients may support different sets of named tracers. Custom JavaScript tracers may also be supplied as an expression string.
-
tracerConfig
objectAn optional tracer-specific configuration object passed to the named tracer. Only applicable when the tracer field is set. The fields accepted here depend on the named tracer in use; for "callTracer" this is CallTracerConfig.
Show
tracerConfigobjecttracerConfigfieldsAn optional tracer-specific configuration object passed to the named tracer. Only applicable when the tracer field is set. The fields accepted here depend on the named tracer in use; for "callTracer" this is CallTracerConfig.
-
additionalProperties
true
Result
Transaction trace object or object or unknown
Show Option 1 Opcode tracer result object
Opcode tracer result objectOpcode tracer result fields
Returned when no named tracer is specified.
Transaction trace object
Returned when no named tracer is specified.
Show Transaction trace object
Transaction trace objectTransaction trace fields
-
failed
booleanrequiredWhether the transaction execution failed (reverted or ran out of gas).
-
gas
integerrequiredTotal amount of gas consumed by the transaction.
Range:
>= 0
-
returnValue
stringrequiredThe data returned by the transaction. For a transaction that reverts, this is the revert data. 0x-prefixed hex-encoded bytes. MUST be "0x" (not an empty string) when no data was returned.
Match pattern:
^0x([0-9a-f]{2})*$
-
structLogs
array<object>requiredThe ordered sequence of opcode execution steps. Will be empty for simple ETH transfers between externally owned accounts that execute no EVM code.
Show
structLogsobjectstructLogsfieldsThe ordered sequence of opcode execution steps. Will be empty for simple ETH transfers between externally owned accounts that execute no EVM code.
-
depth
integerrequiredThe call stack depth at this execution step. Starts at 1 for the outermost call.
Range:
>= 1
-
error
stringThe error that halted the frame exceptionally at this step. This field MUST be present, as a non-empty string, at the step whose opcode halts its frame exceptionally. Examples are out of gas, stack underflow or overflow, an invalid jump destination, an undefined or INVALID opcode, a state change in a static context, a return data read out of bounds, and an SSTORE with gas at or below the call stipend (EIP-2200). The text is client-defined. This field MUST be absent at every other step. A REVERT that does not itself fail completes, so this field MUST be absent at that step. A REVERT that fails (e.g. out of gas for its memory expansion) halts exceptionally. This field MUST also be absent for a failure that is not a halt of the step's own opcode, because that step completes: a failed child frame, a failed precompile call, an address collision, a code deposit failure, a value above the balance, and the call depth limit. Clients MUST NOT include this field as null or as an empty string.
>= 1 chars
-
gas
integerrequiredThe amount of gas remaining before executing this opcode.
Range:
>= 0
-
gasCost
integerrequiredThe execution gas that this opcode charged. Includes dynamic costs such as memory expansion and storage access charges (e.g. cold vs. warm SLOAD/SSTORE). For CALL, CALLCODE, DELEGATECALL and STATICCALL, it includes the gas forwarded to the callee and excludes the call stipend. For CREATE and CREATE2, it excludes the gas forwarded to the initcode. A step that completes MUST report this cost. This includes a REVERT that does not itself fail and a CALL whose callee frame is not entered (e.g. because the value is above the balance or the call depth limit is reached). A step whose opcode halts its frame exceptionally MUST report 0. The value 0 means that the trace reports no cost for the step. The halt still consumes all of the frame's remaining gas. From the Amsterdam fork (EIP-8037), it consumes only the execution gas that is left, and the frame's state gas is not consumed.
Range:
>= 0
-
memory
array<string>The contents of EVM memory before this opcode executes, divided into 32-byte chunks. Each element is a 0x-prefixed, zero-padded 32-byte hex word representing a consecutive 32-byte memory slot starting at offset (index * 32). This field MUST be omitted (not null and not an empty array) when enableMemory is false or memory is empty.
Match pattern:
^0x[0-9a-f]{64}$
-
op
stringrequiredThe name of the EVM opcode executed at this step (e.g. "PUSH1", "SSTORE"), from the opcode set that is active at the fork of the block. The name is the mnemonic that the EIP defining the opcode uses (e.g. "KECCAK256", "SELFDESTRUCT"). A byte that is not defined at that fork MUST be named
opcode 0x<byte> not defined, with the byte in lowercase hex and without leading zeros (e.g. "opcode 0xc not defined"). This includes an opcode that a later fork defines, such as PUSH0 (0x5f) before Shanghai. The byte 0xfe MUST be named "INVALID" (EIP-141). The byte 0x44 MUST be named "PREVRANDAO" from the Paris fork (EIP-4399) and "DIFFICULTY" before it.
-
pc
integerrequiredThe program counter position of this opcode in the contract bytecode.
Range:
>= 0
-
refund
integerThe accumulated gas refund counter of the transaction before this opcode executes. This is the counter of the transaction, not a counter for each call frame. It is read before any refund change that this step makes (e.g. an SSTORE refund). A step that halts exceptionally also reports the counter before the step, without the refund change that the step attempted. Clients MUST include this field at every step when it is non-zero and MUST omit it when it is zero.
Range:
>= 0
-
returnData
stringThe contents of the return data buffer (the data RETURNDATASIZE and RETURNDATACOPY read) before this opcode executes. This field MUST be omitted (not null and not "0x") when enableReturnData is false or the buffer is empty.
Match pattern:
^0x([0-9a-f]{2})*$
-
stack
array<string>The contents of the EVM stack before this opcode executes, ordered from bottom (index 0) to top (last element). Each value is a 0x-prefixed uint256 quantity. This field MUST be omitted when disableStack is true. Otherwise it MUST be present, as an empty array when the stack is empty.
Match pattern:
^0x(0|[1-9a-f][0-9a-f]{0,63})$
-
storage
objectA cumulative snapshot of all storage slots accessed or modified by the current contract up to and including this step. Keys are 0x-prefixed, zero-padded 32-byte storage slot indices; values are the 32-byte stored values reflecting the post-execution state of the opcode at this step (i.e., for SSTORE, the value reflects the new value just written). This field is only populated at SLOAD and SSTORE opcodes. At all other opcodes, this field MUST be absent (not an empty object). An SLOAD or SSTORE step that halts with an error does not execute the opcode, so this field MUST be absent at that step, and the step MUST NOT add or update the slot in the snapshot of later steps. This field is absent when disableStorage is true.
Show
storageobjectstoragefieldsA cumulative snapshot of all storage slots accessed or modified by the current contract up to and including this step. Keys are 0x-prefixed, zero-padded 32-byte storage slot indices; values are the 32-byte stored values reflecting the post-execution state of the opcode at this step (i.e., for SSTORE, the value reflects the new value just written). This field is only populated at SLOAD and SSTORE opcodes. At all other opcodes, this field MUST be absent (not an empty object). An SLOAD or SSTORE step that halts with an error does not execute the opcode, so this field MUST be absent at that step, and the step MUST NOT add or update the slot in the snapshot of later steps. This field is absent when disableStorage is true.
-
additionalProperties
true
-
-
additionalProperties
true
Show Option 2 Call tracer result object
Call tracer result objectCall tracer result fields
Returned when the tracer field is "callTracer".
Transaction trace object
Returned when the tracer field is "callTracer".
Show Transaction trace object
Transaction trace objectTransaction trace fields
-
error
stringThe error that halted the frame. MUST be omitted on success. MUST be exactly "execution reverted" when the frame halted due to REVERT; other failure messages are client-specific free text, but SHOULD identify the failure class (e.g. out of gas, write protection).
-
from
stringrequiredThe address the frame executes on behalf of. For DELEGATECALL and CALLCODE frames this is the calling frame's context address, including in nested delegatecall chains.
Match pattern:
^0x[0-9a-fA-F]{40}$
-
gas
stringrequiredgas provided
Match pattern:
^0x(0|[1-9a-f][0-9a-f]*)$
-
gasUsed
stringrequiredgas used
Match pattern:
^0x(0|[1-9a-f][0-9a-f]*)$
-
input
stringrequiredThe call data, or the initcode for CREATE/CREATE2 frames. Always present; "0x" when empty.
Match pattern:
^0x([0-9a-f]{2})*$
-
logs
array<object>Logs emitted by this frame. Only present when the withLog tracer option is set. MUST be omitted when the frame emitted no logs, and MUST be omitted from reverted frames and their descendants, whose logs never take effect.
Show
logsobjectlogsfieldsLogs emitted by this frame. Only present when the withLog tracer option is set. MUST be omitted when the frame emitted no logs, and MUST be omitted from reverted frames and their descendants, whose logs never take effect.
-
address
stringrequiredlog emitter
Match pattern:
^0x[0-9a-fA-F]{40}$
-
data
stringrequiredlog data
Match pattern:
^0x([0-9a-f]{2})*$
-
index
stringrequiredThe log's index within the block: the number of logs that took effect in the block before this one, counting the logs of all preceding transactions. It MUST equal the logIndex of the same log in the transaction receipt. Logs of reverted frames never take effect and do not consume an index, and onlyTopCall does not change the numbering. For debug_traceCall, where no receipt exists, numbering starts at zero for the traced call.
Match pattern:
^0x(0|[1-9a-f][0-9a-f]*)$
-
position
stringrequiredThe number of subcalls the containing frame had created when this log was emitted; i.e. the log's position relative to the frame's calls array, allowing the interleaving of logs and subcalls to be reconstructed. When onlyTopCall is set, no subcall frames are collected and position is 0 for every log.
Match pattern:
^0x(0|[1-9a-f][0-9a-f]*)$
-
topics
array<string>required32 hex encoded bytes
Match pattern:
^0x[0-9a-f]{64}$
-
additionalProperties
true
-
-
output
stringThe data returned by the frame, or the deployed runtime code for successful CREATE/CREATE2 frames. On a reverted frame this is the raw revert data. MUST be omitted when empty.
Match pattern:
^0x([0-9a-f]{2})*$
-
revertReason
stringThe human-readable revert reason. MUST be present if and only if the frame reverted and its revert data decodes as the standard Panic(uint256) ABI encoding, or as Error(string) with a non-empty string. For Error(string) it is the decoded string. For Panic(uint256) it is a short description of the panic code; the exact text is client-defined.
-
to
stringThe call target, created contract address (CREATE/CREATE2), or refund beneficiary (SELFDESTRUCT). MUST be present on all frames except CREATE and CREATE2 frames that failed, where it MUST be omitted since no contract was created.
Match pattern:
^0x[0-9a-fA-F]{40}$
-
type
stringrequiredThe frame's opcode mnemonic. The root frame is CALL for a message call transaction or CREATE for a deployment transaction.
Allowed values:
CALLCALLCODEDELEGATECALLSTATICCALLCREATECREATE2SELFDESTRUCT
-
value
stringThe value transferred by this frame in wei. MUST be present, including when zero, for all frame types except STATICCALL, where it MUST be omitted. For DELEGATECALL frames this is the value of the calling context (delegatecall transfers no value itself).
Match pattern:
^0x(0|[1-9a-f][0-9a-f]{0,63})$
-
additionalProperties
true
Show Option 3 Named tracer result
Named tracer result Named tracer result fields
Returned when another named tracer is specified via the tracer field. The format is tracer-specific and not defined by this specification. Named tracers may return any JSON value (object, array, integer, etc.).
Errors
Error code: 4444
-
code
4444
-
message
Pruned history unavailable
Examples
debug_traceTransaction example (opcode tracer)
Request
{
"params": [
"0xdd8cf045113754c306ba9ac8ac8786235e33bc5c087678084ef260a2a583f127",
{
"disableStack": false,
"disableStorage": false,
"enableMemory": false,
"enableReturnData": false
}
]
}
Response
{
"failed": false,
"gas": 26916,
"returnValue": "0x",
"structLogs": [
{
"depth": 1,
"gas": 68612,
"gasCost": 3,
"op": "PUSH1",
"pc": 0,
"stack": []
},
{
"depth": 1,
"gas": 68609,
"gasCost": 3,
"op": "PUSH1",
"pc": 2,
"stack": [
"0x60"
]
},
{
"depth": 1,
"gas": 68606,
"gasCost": 12,
"op": "MSTORE",
"pc": 4,
"stack": [
"0x60",
"0x40"
]
}
]
}
debug_traceTransaction example (callTracer)
Request
{
"params": [
"0xdd8cf045113754c306ba9ac8ac8786235e33bc5c087678084ef260a2a583f127",
{
"tracer": "callTracer",
"tracerConfig": {
"onlyTopCall": false,
"withLog": true
}
}
]
}
Response
{
"from": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73",
"gas": "0x1a49e",
"gasUsed": "0x1a49e",
"input": "0x",
"output": "0x",
"to": "0x0100000000000000000000000000000000000000",
"type": "CALL",
"value": "0x0"
}