🟪 Polygon
debug_traceCall

Polygon API Documentation


debug_traceCall RPC Method

debug_traceCall is a Polygon method that returns the number of possible tracing result by executing an eth_call within the context of the given block execution.


💡

debug_traceCall is useful for testing and debugging smart contracts as it allows you to see how a call to a contract function would execute and what it would return, without having to send a real transaction or use any gas.

Parameters

1.TRANSACTION CALL OBJECT [required]

object - The eth_call data

  • from [optional] - The address from which the transaction is sent.

  • to - The address where the transaction is sent to.

  • gas [optional] - Integer of the gas provided for the transaction execution. Although eth_call consumes zero gas, this parameter may still be needed by some executions.

  • gasPrice [optional] - Integer of the gasPrice used for each paid gas as hexadecimal.

  • value [optional] - Interger of the value sent with a stated transaction

  • data [optional] - Hash of the method signature and encoded parameters. More info 👉 Ethereum Contract ABI (opens in a new tab)

2.BLOCK PARAMETER [required]

💡 Confusing?

Ask our experienced blockchain developers in Telegram

3.TRACE TYPE [optional]

  • The type of tracer - String - It might 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 - The object to specify the configurations of the tracer

    • onlyTopCall - 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.

Additional configuration parameters

  • disableStorage — when enabled, it prevents tracing of storage changes made by the transaction being analyzed, which can reduce the resource requirements of the analysis. By default, debug_traceTransaction traces both memory and storage changes, but storage tracing can be particularly resource-intensive, especially for large transactions.

  • disableStack — when enabled, it skips tracing of stack changes made by the transaction being analyzed.

  • disableMemory — when true, it stops tracing of memory changes made by the transaction being analyzed, reducing resource requirements.

  • disableReturnData — when true, it prevents the method from tracing the return data of a transaction. This return data tracing can be very demanding on resources, as it requires a lot of time and processing power.

  • timeout (default: 5s) — allows to customize the method's timeout period for JavaScript-based tracing calls.

💡

When using one of the three tracers, the disableMemory, disableStorage, disableStack, and disableReturnData will not have any effect.

When no tracer is selected, the response defaults to the Struct/opcode logger (opens in a new tab).

Need RPC API keys?

Get 12.5M archival requests for free today.

Returns

callTracer response

FieldDescription
type of the callType of the call
fromThe transaction sender.
toThe address of the transaction recipient.
gasThe gas included in the transaction by the sender.
transaction valueThe actual value per gas deducted from the sender's account.
gasUsedThe total used gas by the call. Encoded as hexadecimal.
inputThe optional input data sent with the transaction, usually used to interact with smart contracts.
outputThe return value of the call, encoded as a hexadecimal string.
errorAn error message in case the execution failed.
callsA list of sub-calls made by the contract during the call, each represented as a nested call frame object.
revertReasonThe reason why the transaction was reverted, returned by the smart contract if any.

prestateTracer response

  • smart contract address — The address of the smart contract associated with the result.

    • balance — The balance of the contract, expressed in wei and encoded as a hexadecimal string.

    • code — The bytecode of the contract, encoded as a hexadecimal string.

    • nonce — The nonce of the account associated with the contract, represented as an unsigned integer.

    • storage — A map of key-value pairs representing the storage slots of the contract. The keys and values are both encoded as hexadecimal strings.

Struct/opcode response

  • The transaction trace object:

  • failed - Successful or failed

  • gas - The total consumed gas in the transaction

  • returnValue - The return value of the executed contract call

  • structLogs - The trace result of each step:

    • 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.

    • stack - An array of values in the current stack.

    • storage - The mapping of the current storage.

    • refund - The total of current refund value.

    • error- The error of the execution.

    • memory - An array of values in the current memory.

Request

POST https://<network>.chainnodes.org/YOUR-API-KEY

Example

  • HTTPS POST Request with a JSON RPC call in the body
  • Replace YOUR-API-KEY with the API key from your CHAINNODES.ORG Dashboard
  • You can use a different supported network by replacing polygon-mainnet
curl https://polygon-mainnet.chainnodes.org/YOUR-API-KEY \
    -X POST \
    -H "Content-Type: application/json" \
    -d '{"method":"debug_traceCall","params":[{"to": "0x6d2e03b7effeae98bd302a9f836d0d6ab0002766", "gasPrice": "0x174876E800"} ,"latest" ],"id":1,"jsonrpc":"2.0"}'

Body

{
"jsonrpc":"2.0",
"id":1,
"result":{
"structLogs":[
],
"gas":21000,
"failed":false,
"returnValue":""
}
}

JSON-RPC Polygon API Documentation by CHAINNODES is based on Erigon node client. Contact us if you are interested in specific methods that are only available on geth, besu, Nethermind or reth