debug_traceBlockByHash

Ethereum RPC

Archive Method

Only on the full archive nodes. Complex queries might take longer and incur additional cost

Overview

debug_traceBlockByHashmethod allows developers to trace the execution of transactions within a block specified by its hash. This method is particularly useful for debugging purposes, as it provides detailed information about the execution of each transaction within the block, including the type of call, the addresses involved, the value transferred, the gas used, the input data, the output data, and any sub-calls made during the transaction.

Parameters

1.blockHash (required)

A string representing the hash of the block to be traced.

2.tracer (required)

An object that specifies the tracer to use for the transaction trace, one of the following:

NameTypeRequiredDescription
callTracerstringYesTracks all call frames generated during a transaction, including those at depth 0.
prestateTracerstringYesReplays the transaction and monitors every aspect of the state that occurred throughout the process.

tracerConfig

An object that allows specifying configurations for the tracer:

NameTypeRequiredDescription
onlyTopCallbooleanYesA boolean indicating whether to trace only the top-level call or all sub-calls.

Returns

callTracer response

NameDescription
type of the callThe type of the call.
fromThe address from which the transaction is sent.
toThe address to which the transaction is directed.
gasThe integer value of the gas used.
transaction valueThe specific amount deducted from the sender's account per unit of gas consumed.
gasUsedThe total gas consumed during the call, represented in hexadecimal format.
inputThe input data accompanying the transaction, optionally provided, typically utilised for interacting with smart contracts.
outputThe data returned as output from the transaction.
errorThe type of error encountered during the transaction, if any.
revertReasonThe Solidity revert reason, if any.
callsA list of sub-calls made during the transaction's execution.

prestateTracer response

NameDescription
smart contract addressThe smart contract address linked to the outcome.
balanceThe balance of the contract , shown in hexadecimal format, and measured in wei.
codeThe contract's bytecode encoded as a hexadecimal string
nonceThe account's nonce connected to the contract, shown as a unsigned integer
storageA collection of pairs showing the storage slots of the contract, with both keys and values encoded in hexadecimal format.

Request Example

curl --location 'https://api.tatum.io/v3/blockchain/node/ethereum-mainnet/' \
--header 'Content-Type: application/json' \
--header 'x-api-key: {API_KEY}' \
--data '{
    "method": "debug_traceBlockByHash",
    "params": [
        "0x97b49e43632ac70c46b4003434058b18db0ad809617bd29f3448d46ca9085576",
        {
            "tracer": "callTracer"
        }
    ],
    "id": 1,
    "jsonrpc": "2.0"
}'
// yarn add @tatumio/tatum

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

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

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

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