trace_block

Ethereum RPC

How to use it

// yarn add @tatumio/tatum

import { TatumSDK, Ethereum, Network } from '@tatumio/tatum'

const tatum = await TatumSDK.init<Ethereum>({ network: Network.ETHEREUM })

const blockTrace = await tatum.rpc.traceBlock({ blockNumber: 10123321 })

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

Overview

trace_block is a JSON-RPC method that allows you to fetch the trace details for a given block based on the block height. This method can be useful when you need detailed trace information for a specific block.

Use cases for this method may include:

  • Analyzing the internal operations of transactions within a block
  • Debugging smart contract interactions
  • Collecting data for in-depth blockchain analytics

Parameters

The trace_block method accepts one parameter:

  1. blockNumber (required): The height of the block for which you want to fetch trace details.
    • Example: 10123321

Return Object

The method returns a JSON object containing trace details of the specified block. The structure of the returned object includes the following fields:

  1. action: An object containing details about the action performed in the trace.
    • from: The address of the sender.
    • callType: The type of call made (e.g., "call").
    • gas: The amount of gas provided by the sender.
    • input: The input data sent along with the transaction.
    • to: The address of the recipient.
    • value: The value transferred in wei.
  2. blockHash: The hash of the block containing the trace.
  3. blockNumber: The height of the block containing the trace.
  4. result: An object containing the result of the trace.
    • gasUsed: The amount of gas used by the transaction.
    • output: The output data from the transaction.
  5. subtraces: The number of subtraces within this trace.
  6. traceAddress: An array indicating the trace address.
  7. transactionHash: The hash of the transaction containing the trace.
  8. transactionPosition: The position of the transaction within the block.
  9. type: The type of the trace (e.g., "call").

JSON Examples

Request:

{
  "jsonrpc": "2.0",
  "id": 67,
  "method": "trace_block",
  "params": [10123321]
}

Response:

{
  "jsonrpc": "2.0",
  "id": 67,
  "result": [
    {
      "action": {
        "from": "0xcabda7c04a240498636ee0e535e0596b504c66d2",
        "callType": "call",
        "gas": "0x0",
        "input": "0x",
        "to": "0x3cd76d4a67ebd1c88cd8cf613c4551199cccae4d",
        "value": "0x46bdf53e068dc0000"
      },
      "blockHash": "0x103eca282ca064902fa3e15ad705bcf52cff6a5d0e9ad7b077a503268f6aa317",
      "blockNumber": 10123321,
      "result": {
        "gasUsed": "0x0",
        "output": "0x"
      },
      "subtraces": 0,
      "traceAddress": [],
      "transactionHash": "0x93f11750429ae0f792a584b0dca215c52c40b506086ceb16fb3200932939116f",
      "transactionPosition": 0,
      "type": "call"
    }
  ]
}