[Trace] debug_traceTransaction
The traceTransaction debugging method will attempt to run the transaction in the exact same manner as it was executed on the network. It will replay any transaction that may have been executed prior to this one before it will finally attempt to execute the transaction that corresponds to the given hash.
JSONRPC: debug_traceTransaction
Request
- application/json
Body
Array [
]
params
undefined[]
The hash of the transaction.
TracingOptions
object
Setting this to true will disable storage capture in the null (structLog) tracer (default: false).
Setting this to true will disable memory capture in the null (structLog) tracer (default: false).
Setting this to true will disable stack capture in the null (structLog) tracer (default: false).
Overrides the default timeout of 5 seconds for trace-enabled EVM execution. A duration string can be anything that is accepted by Go time.ParseDuration function such as "10s" or "300ms".
Possible values: [null
, 4byteTracer
, callTracer
, fastCallTracer
, evmdisTracer
, noopTracer
, opcountTracer
, prestateTracer
, revertTracer
, unigramTracer
, bigramTracer
, trigramTracer
, custom javascript tracer code
]
If this field is empty or null, then the structLog tracer is used where the execution of every opcode is shown in detail. This null tracer is extremely heavy and usually too verbose for any debugging purpose, so it is advised to use other predefined tracers. This field can be the name of one of the predefined tracers shown below.
Tracer Name | Description |
---|---|
4byteTracer | traces 4-byte solidity function signatures. |
callTracer | a slow version of fastCallTracer. It is deprecated in favor of fastCallTracer. |
fastCallTracer | traces internal contract calls, gas usage, and call results. |
evmdisTracer | returns information needed to perform evmdis-style disassembly. |
noopTracer | is a template tracer that does nothing. |
opcountTracer | is a sample tracer that counts the executed opcode. |
prestateTracer | returns information needed to construct a custom local genesis state that this transaction can run on. |
revertTracer | returns the revert reason, or an empty string if the transaction has not reverted. |
unigramTracer | counts the occurrence of each opcode. |
bigramTracer | counts the occurrence of two consecutive opcodes. |
trigramTracer | counts the occurrence of three consecutive opcodes. |
Otherwise this field is interpreted as a piece of javascript code. You can find more about custom JS tracer here and here. Below is an example custom tracer that prints the gasUsed after each opcode "{gasUsed: [], step: function(log) { this.gasUsed.push(log.getGas()); }, result: function() { return this.gasUsed; }, fault: function() {}}"
. Note that some nodes with --rpc.unsafe-debug.disable
option will prohibit custom tracer.
Responses
- 200
The structured logs created during the execution of KLVM.
- application/json
- Schema
- Example (from schema)
Schema
Array [
]
error
object
A Number that indicates the error type that occurred. This MUST be an integer.
code | message | description |
---|---|---|
-32700 | Parse error | invalid JSON was received by the server. An error occurred on the server while parsing the JSON text. |
-32602 | Invalid params | Invalid method parameter(s). |
A String providing a short description of the error. The message SHOULD be limited to a concise single sentence.
A Primitive or Structured value that contains additional information about the error. This may be omitted. The value of this member is defined by the Server (e.g. detailed error information, nested errors etc.).
result
object
The structured logs created during the execution of KLVM.
structLogs
object[]
required
The status of the response
The status of the response
{
"jsonrpc": "2.0",
"id": 0,
"error": {
"code": -32700,
"message": "Parse error",
"data": "string"
},
"result": {
"failed": false,
"gas": 28110,
"returnValue": "",
"structLogs": [
{
"computation": 149999880,
"computationCost": 120,
"depth": 1,
"gas": 6710,
"gasCost": 3,
"memory": [],
"op": "PUSH1",
"pc": 0,
"stack": [],
"storage": {}
},
{
"computation": 149999760,
"computationCost": 120,
"depth": 1,
"gas": 6707,
"gasCost": 3,
"memory": [],
"op": "PUSH1",
"pc": 2,
"stack": [
"0000000000000000000000000000000000000000000000000000000000000080"
],
"storage": {}
},
{
"...": null
},
{
"computation": 149965613,
"computationCost": 0,
"depth": 1,
"gas": 0,
"gasCost": 0,
"memory": [
"0000000000000000000000000000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000000000000000000000000080",
"0000000000000000000000000000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000000000000000000000000002"
],
"op": "STOP",
"pc": 176,
"stack": [
"00000000000000000000000000000000000000000000000000000000d09de08a"
],
"storage": {
"0": "0000000000000000000000000000000000000000000000000000000000000002"
}
}
]
}
}