debug_traceCall-polygon

The debug_traceCall method lets you run an eth_call within the context of the given block execution using the final state of parent block as the base. The first argument (just as in eth_call) is a transaction object. The block can be specified either by hash or by number as the second argument. The trace can be configured similar to debug_traceTransaction, see TraceConfig. The method returns the same output as debug_traceTransaction.

Parameters

  • Object - The transaction call object
    • from: DATA, 20 Bytes - The address the transaction is sent from.
    • to: DATA, 20 Bytes - (optional when creating new contract) The address the transaction is directed to.
    • gas: QUANTITY - (optional, default: 90000) Integer of the gas provided for the transaction execution. It will return unused gas.
    • gasPrice: QUANTITY - (optional, default: To-Be-Determined) Integer of the gasPrice used for each paid gas.
    • value: QUANTITY - (optional) Integer of the value sent with this transaction.
    • data: DATA - The compiled code of a contract OR the hash of the invoked method signature and encoded parameters.
    • nonce: QUANTITY - (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.
  • hash|QUANTITY|TAG - block hash, or hex encoded integer block number, or the string "latest", "earliest" or "pending", see the default block parameter
  • 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://polygon-mainnet-archive.allthatnode.com:8545/8U3JLUhzIDg3GShvy9hkCCSYkLGc11kj \
--request POST \
--header "Content-Type: application/json" \
--data '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "debug_traceCall",
  "params": [
    {
      "from": "0xe7547f9e11b48a7c6e4cfe47f267cd9fc2459464",
      "to": "0xbb5f9ade0023ae87bdcd2268bdd74a2711654bdb",
      "gas": "0xCE1484ABA",
      "gasPrice": "0x150771E8BA",
      "value": "0x0",
      "data": "0x520ea9dc00000000000000000000000000000000000000000000000000000000000000c8"
    },
    "latest",
    {
      "enableMemory": true,
      "disableStack": false,
      "disableStorage": false,
      "enableReturnData": true
  }
  ]
}'

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": "0xe7547f9e11b48a7c6e4cfe47f267cd9fc2459464",
    "gas": "0x2fa9dac",
    "gasUsed": "0x224d6",
    "to": "0xbb5f9ade0023ae87bdcd2268bdd74a2711654bdb",
    "input": "0x520ea9dc00000000000000000000000000000000000000000000000000000000000000c8",
    "output": "0x924e15fb0000000000000000000000000000000000000000000000000000000000000190",
    "error": "execution reverted",
    "calls": [
      {
        "from": "0xbb5f9ade0023ae87bdcd2268bdd74a2711654bdb",
        "gas": "0x2ee972e",
        "gasUsed": "0x1b55b",
        "to": "0x9826309fd1925d5aa46365d5dd39c06c480384c7",
        "input": "0x520ea9dc00000000000000000000000000000000000000000000000000000000000000c8",
        "output": "0x924e15fb0000000000000000000000000000000000000000000000000000000000000190",
        "error": "execution reverted",
        "calls": [
          {
            //calls
          }
        ],
        "type": "DELEGATECALL"
      }
    ],
    "value": "0x0",
    "type": "CALL"
  }
}

Try Yourself

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