🟪 Polygon
debug_traceBlockByNumber

Polygon API Documentation


debug_traceBlockByNumber RPC Method

The debug_traceBlockByNumber returns traces for a full block, for all transactions in the block.

️💡

Use debug_traceBlockByNumber free of charge 👉 CHAINNODES API (opens in a new tab)

Parameters

  • blockNumber or Tag - [required] - Block number as hexadecimal or the Tag ("latest", "earliest", "pending", "safe" or "finalized").

"Safe" and "finalized" are only availible on Ethereum and Arbitrum One chains. Read block parameter description (opens in a new tab).

  • tracer object - [optional] - with :

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

Returns

Depending on the tracer type you have chosen, returns a callTracer object or prestateTracer object.

callTracer response

FieldDescription
type of the callType of the call
fromThe address the transaction was sent from.
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 if 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

Example

💡

Confusing? Ask blockchain developers in Chainnodes Telegram Chat (opens in a new tab)

  • 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 network by replacing polygon-mainnet
curl https://polygon-mainnet.chainnodes.org/YOUR-API-KEY \
    -X POST \
    -H "Content-Type: application/json" \
    -d '{"method":"debug_traceBlockByNumber","params":["latest", {"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.

JSON-RPC 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.