debug_traceBlockByNumber

Replays the block that is already present in the database.

📘

NOTE

When using this endpoint on Arbitrum: Following the hard-fork from Classic to Nitro, all debug_trace methods can only be used for blocks starting from block 22,207,818 onwards

Parameters

  1. blockNumber - This describes the block number to fetch the transaction by.
  2. Object - tracer
  • tracer - string to specify the type of tracer. Currently supports callTracer and prestateTracer (see below for definitions).
  • tracerConfig - Object to specify configurations for the tracer
    • onlyTopCall - boolean Setting this to true will only trace the main (top-level) call and none of the sub-calls. This avoids extra processing for each call frame if only the top-level call info are required (useful for getting revertReason).

Returns

  • Object - trace object

Request

curl https://eth-mainnet.g.alchemy.com/v2/demo \
 -X POST \
 -H "Content-Type: application/json" \
 --data '{"method":"debug_traceBlockByNumber",
       "params":[
           "0xECE410", 
           {"tracer": "callTracer"}
          ],
        "id":1,
        "jsonrpc":"2.0"
       }'

Response

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "type": "CALL",
    "from": "0x0000000000000000000000000000000000000000",
    "to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
    "value": "0x0",
    "gas": "0x7fffffffffffadf7",
    "gasUsed": "0x0",
    "input": "0x",
    "output": "0x"
  }
}

callTracer

The callTracer tracks all the call frames executed during a transaction, including depth 0. The result will be a nested list of call frames, resembling how EVM works. They form a tree with the top-level call at root and sub-calls as children of the higher levels. Each call frame has the following fields:

fieldtypedescription
typestringCALL or CREATE
fromstringaddress
tostringaddress
valuestringhex-encoded amount of value transfer
gasstringhex-encoded gas provided for call
gasUsedstringhex-encoded gas used during call
inputstringcall data
outputstringreturn data
errorstringerror, if any
revertReasonstringSolidity revert reason, if any
calls[]callframelist of sub-calls

Things to note about the call tracer:

  • Calls to precompiles are also included in the result
  • In case a frame reverts, the field output will contain the raw return data
  • In case the top level frame reverts, its revertReason field will contain the parsed reason of revert as returned by the Solidity contract
  • Setting the tracerConfig of onlyTopCall to true will only trace the main (top-level) call and none of the sub-calls

prestateTracer

Executing a transaction requires the prior state, including account of sender and recipient, contracts that are called during execution, etc. The prestateTracer replays the tx and tracks every part of state that is touched during that transaction. This is similar to the concept of a stateless witness, the difference being this tracer doesn’t return any cryptographic proof, rather only the trie leaves. The result is an object. The keys are addresses of accounts. The value is an object with the following fields:

fieldtypedescription
balancestringbalance in wei
nonceuint64nonce
codestringhex-encoded bytecode
storagemap[string]stringstorage slots of the contract

📘

NOTE

You can test out this method live from your browser using our composer tool.

Language
URL
ReadMe