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. OBS In most scenarios, debug.standardTraceBlockToFile is better suited for tracing!

Parameters

  • transactionHash - the transaction hash of the transaction that needs to be traced.
  • object- (Optional) The tracer object with the following fields:
    • disableStorage: boolean - Setting this to true will disable storage capture (default = false).
    • disableStack: boolean - Setting this to true will disable stack capture (default = false).
    • enableMemory: boolean - Setting this to true will disable memory capture (default = false).
    • enableReturnData: boolean - Setting this to true will disable stack capture (default = false).
    • tracer: string - The type of tracer. It could be callTracer or prestateTracer
      • callTracer - The calltracer keeps track of all call frames, including depth 0 calls, that are made during a transaction
      • prestateTracer - The prestateTracer replays the transaction and tracks every part of state that occured during the transaction
    • tracerConfig: object - The object to specify the configurations of the tracer
      • onlyTopCall: boolean - When set to true, this will only trace the primary (top-level) call and not any sub-calls. It eliminates the additional processing for each call frame
curl https://ethereum-mainnet-archive.allthatnode.com/8U3JLUhzIDg3GShvy9hkCCSYkLGc11kj \
--request POST \
--header "Content-Type: application/json" \
--data '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "debug_traceTransaction",
  "params": [
    "0x685aa677823b75ca0e13777486fdc008e135694fb80495ca54bffee05d6a7901",
    {
      "enableMemory": true,
      "disableStack": false,
      "disableStorage": false,
      "enableReturnData": true,
      "timeout": "300ms"
  }
  ]
}'

Returns

  • object - trace object
    • failed - The transaction is successful or not
    • gas - The total consumed gas in the transaction
    • returnValue - The return value of the executed contract call
    • structLogs - The trace result of each step with the following fields:
      • pc - The current index in bytecode
      • op - The name of current executing operation
      • gas - The available gas in the execution
      • gasCost - The gas cost of the operation
      • depth - The number of levels of calling functions
      • error - The error of the execution
      • stack - An array of values in the current stack
      • memory - An array of values in the current memory
      • storage - The mapping of the current storage
      • refund - The total of current refund value
//with default tracer option
{
    "jsonrpc": "2.0",
    "id": 1,
    "result": {
        "gas": 21045,
        "failed": true,
        "returnValue": "",
        "structLogs": [
            {
                "pc": 0,
                "op": "PUSH1",
                "gas": 465400,
                "gasCost": 3,
                "depth": 1,
                "stack": [],
                "memory": []
            },
            {
                "pc": 2,
                "op": "PUSH1",
                "gas": 465397,
                "gasCost": 3,
                "depth": 1,
                "stack": [
                    "0x80"
                ],
                "memory": []
            },
            {
                "pc": 4,
                "op": "MSTORE",
                "gas": 465394,
                "gasCost": 12,
                "depth": 1,
                "stack": [
                    "0x80",
                    "0x40"
                ],
                "memory": []
            },
            {
                "pc": 5,
                "op": "CALLVALUE",
                "gas": 465382,
                "gasCost": 2,
                "depth": 1,
                "stack": [],
                "memory": [
                    "0000000000000000000000000000000000000000000000000000000000000000",
                    "0000000000000000000000000000000000000000000000000000000000000000",
                    "0000000000000000000000000000000000000000000000000000000000000080"
                ]
            },
            //more objects
            {
                "pc": 14,
                "op": "DUP1",
                "gas": 465358,
                "gasCost": 3,
                "depth": 1,
                "stack": [
                    "0x9184e72a",
                    "0x0"
                ],
                "memory": [
                    "0000000000000000000000000000000000000000000000000000000000000000",
                    "0000000000000000000000000000000000000000000000000000000000000000",
                    "0000000000000000000000000000000000000000000000000000000000000080"
                ]
            },
            {
                "pc": 15,
                "op": "REVERT",
                "gas": 465355,
                "gasCost": 0,
                "depth": 1,
                "stack": [
                    "0x9184e72a",
                    "0x0",
                    "0x0"
                ],
                "memory": [
                    "0000000000000000000000000000000000000000000000000000000000000000",
                    "0000000000000000000000000000000000000000000000000000000000000000",
                    "0000000000000000000000000000000000000000000000000000000000000080"
                ]
            }
        ]
    }
}


//with callTracer option
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "from": "0xc5a93444cc4da6efb9e6fc6e5d3cb55a53b52396",
    "gas": "0x76c00",
    "gasUsed": "0x5208",
    "to": "0x7c4cbc1c8cb34e3ae021e66efda4c69d759ff499",
    "input": "0x",
    "value": "0x9184e72a",
    "type": "CALL"
  }
}

Try Yourself

Language
Click Try It! to start a request and see the response here!