arbtrace_block | Arbitrum

Arbitrum API method that enables the tracing of the execution of a specific block using its number. This method can be used to troubleshoot and analyze smart contracts and transactions on the Arbitrum blockchain. It provides an in-depth trace of the block execution, with details on all the interactions, such as transactions and calls, that took place.

πŸ“˜

Learn how to deploy a node with the debug and trace API methods enabled.

🚧

Blocks older than 22,207,815th were added to the chain before Nitro migration and cannot be queried with Geth methods. Starting from block 22,207,815, Arbitrum migrated to Nitro which made Geth debug_* methods available for newer blocks.

Use the arbtrace_block method for calling blocks prior to 22,207,815.

Parameters

  • quantity β€” the integer of a block encoded as hexadecimal or the string.

Response

  • result β€” an object containing the traces of all of the transactions in the block:
    • action β€” an object that describes the action taken by the transaction:
      • from β€” the address of the sender who initiated the transaction.
      • callType β€” the type of call, call or delegatecall, two ways to invoke a function in a smart contract. call creates a new environment for the function to work in, so changes made in that function won't affect the environment where the function was called. delegatecall doesn't create a new environment. Instead, it runs the function within the environment of the caller, so changes made in that function will affect the caller's environment.
      • gas β€” the units of gas included in the transaction by the sender.
      • input β€” the optional input data sent with the transaction, usually used to interact with smart contracts.
      • to β€” the address of the recipient of the transaction if it was a transaction to an address. For contract creation transactions, this field is null.
      • value β€” the value of the native token transferred along with the transaction in Wei.
      • blockHash β€” the hash of the block in which the transaction was included.
      • blockNumber β€” the number of the block in which the transaction was included.
      • error β€” a string that indicates whether the transaction was successful or not. null if successful, Reverted if not.
      • result β€” an object that contains additional data about the execution of the transaction:
        • gasUsed β€” the total used gas by the call, encoded as hexadecimal.
        • output β€” the return value of the call, encoded as a hexadecimal string.
      • subtraces β€” the number of sub-traces created during execution. When a transaction is executed on the EVM, it may trigger additional sub-executions, such as when a smart contract calls another smart contract or when an external account is accessed.
      • traceAddress β€” an array that indicates the position of the transaction in the trace.
      • transactionHash β€” the hash of the transaction.
      • transactionPosition β€” the position of the transaction in the block.
      • type β€” the type of action taken by the transaction, call or create. call is the most common type of trace and occurs when a smart contract invokes another contract's function. create represents the creation of a new smart contract. This type of trace occurs when a smart contract is deployed to the blockchain.

arbtrace_block code examples

const Web3 = require("web3");
const NODE_URL = "YOUR_CHAINSTACK_ENDPOINT";
const web3 = new Web3(NODE_URL);

// Define the arbtrace_block custom method
web3.extend({
    property: 'arbtrace',
    methods: [{
      name: 'arbTraceBlock',
      call: 'arbtrace_block',
      params: 1,
      inputFormatter: [web3.extend.formatters.inputBlockNumberFormatter],
      outputFormatter: web3.extend.formatters.outputBlockFormatter
    }]
  });
  
  async function arbTraceBlock(block) {
      const result = await web3.arbtrace.arbTraceBlock(block);
      console.log(result);
  }
  
  arbTraceBlock("0x152dd42");
const ethers = require('ethers');
const NODE_URL = "YOUR_CHAINSTACK_ENDPOINT";
const provider = new ethers.JsonRpcProvider(NODE_URL);

const arbtraceBlock = async (block) => {

  const traces = await provider.send("arbtrace_block", [block]);
  console.log(traces);
};

arbtraceBlock("0x152dd42")
from web3 import Web3  
node_url = "YOUR_CHAINSTACK_ENDPOINT" 
web3 = Web3.HTTPProvider(node_url)

block = "0x152dd42"

block_traces = web3.provider.make_request('arbtrace_block', [block])
print(block_traces)

Use case

The arbtrace_block method on Arbitrum can be used in analyzing the blocks on the network. By observing the gas supplied by transactions and the corresponding gas consumption, developers can gather valuable information about the behavior of the block. This analysis serves as an initial step toward creating a chain explorer.

Try the arbtrace_block RPC method yourself

Language
Click Try It! to start a request and see the response here!