🟪 Polygon
debug_traceBlockByHash

Polygon API Documentation


debug_traceBlockByHash JSON-RPC Method

The debug_traceBlockByHash allows you to trace the execution of all transactions included in a specific block, identified by its hash, on the Polygon network.

️💡

Please note that you can use debug_traceBlockByHash with no extra fee 👉 here (opens in a new tab)

Parameters

  • block hash - [required] - The hash of the block you trace


  • tracer object - [optional] - An object that defines the type of tracing that should be performed. If not provided, a default tracer will be used. :

    • 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 top-level call and not any sub-calls. It eliminates the additional processing for each call frame.

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.

Request

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

💡 Confusing?

Ask our experienced blockchain developers in Telegram

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_traceBlockByHash","params":["0x97b49e43632ac70c46b4003434058b18db0ad809617bd29f3448d46ca9085576", {"tracer": "callTracer"}],"id":1,"jsonrpc":"2.0"}'

Body

{"jsonrpc": "2.0",
    "id": 1,
    "result": [
        {
            "result": {
                "from": "0x64bbde373e909501de1309231336761adeaa07d5",
                "gas": "0x4b26c",
                "gasUsed": "0x2a421",
                "to": "0xa57bd00134b2850b2a1c55860c9e9ea100fdd6cf",
                "input": 
"0x1cff79cd000000000000000000000000f424018c3d4473e014c1def44171772059f2d720000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001042fdc7315000000000000000000000000f232d640a5700724748464ba8bd8bed21db609a600000000000000000000000000c83aecc790e8a4453e5dd3b0b4b3680501a7a700000000000000000000000056178a0d5f301baf6cf3e1cd53d9863437345bf900000000000000000000000000000000000000000000c4f6b375a9560f1dc9700000000000000000000000000000000000000000003e09de2596099e2b000000000000000000000000000000000000000000000000000000000061c7edb4810f00000000000000000000000000000000000000000000000000000000616a30c2330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
                "calls": [
                    {
                        "from": "0xa57bd00134b2850b2a1c55860c9e9ea100fdd6cf",
                        "gas": "0x49451", 
                        ................
 
}

Need RPC API keys?

Get 12.5M archival requests for free today.

debug_traceBlockByHash JSON-RPC Method Documentation by CHAINNODES