debug_traceBlock

How to use it

// yarn add @tatumio/tatum

import { TatumSDK, XinFin, Network } from '@tatumio/tatum'
  
const tatum = await TatumSDK.init<XinFin>({ network: Network.XINFIN })

const result = await tatum.rpc.debugTraceBlock('0xAD7C5E' ,{
  tracer: 'callTracer',
  tracerConfig: {
      onlyTopCall: true,
      timeout: '5s',
  }
})

await tatum.destroy() // Destroy Tatum SDK - needed for stopping background jobs

Overview

debug_traceBlock is an RPC method that allows developers to trace all transactions within a block using a given tracer. This is particularly useful for analyzing the behavior of all transactions in a block, investigating potential issues, and understanding the flow of execution within smart contracts.

By using the debug_traceBlock, developers can obtain detailed insights into the execution flow of each transaction, allowing for in-depth analysis and debugging

Parameters

  • block - String

    • RLP encoded block object.

  • options (optional): An object containing configuration options for the tracer.

    • tracer: The tracer object with the following fields:

      • callTracer: The calltracer keeps track of all call frames, including depth 0 calls, made during a transaction.

      • prestateTracer: The prestateTracer replays the transaction and tracks every part of the state that occurred during the transaction.

    • tracerConfig: The object to specify the configurations of the tracer.

      • onlyTopCall: When set to true, it traces only the primary (top-level) call and not any sub-calls, eliminating additional processing for each call frame.

Return Object

The return object is an array of all invoked opcodes of all transaction that were included in this block.

  • type: The type of the call.

  • from: The address from which the transaction is sent.

  • to: The address to which the transaction is directed.

  • value: The integer value sent with this transaction.

  • gas: The integer value of the gas provided for the transaction execution.

  • gasUsed: The integer value of the gas used.

  • input: The data given at the time of input.

  • output: The data returned as an output.

  • calls: A list of sub-calls made during the transaction, including detailed trace information for each sub-call.

This method is available only on the full archive node.

JSON-RPC Request and Response Examples

Request

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "debug_traceBlock",
  "params": [
    "0x1dc....",
    {
      "tracer": "callTracer"
    }
  ]
}

Response

{
  "id": 1,
  "jsonrpc": "2.0",
  "result": [
        {
            "result": {