arbtrace_replayBlockTransactions | Arbitrum

Arbitrum API method that replays all the transactions within a specific block and returns the traces. Developers can use the arbtrace_replayBlockTransactions method to gain insight into the behavior of smart contracts within a block, analyze gas usage, and optimize their contracts accordingly.

πŸ“˜

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_replayBlockTransactions method for calling blocks prior to 22,207,815.

Parameters

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

  • array β€” an array identifying the type of tracer and its configuration:

    • trace β€” tracer that captures information on all call frames executed during a transaction. The resulting nested list of call frames is organized into a tree structure that reflects the way the Ethereum Virtual Machine works and can be used for debugging and analysis purposes.

Response

  • output β€” the data returned as a result of the transaction, encoded in hexadecimal format.
  • stateDiff β€” reveals changes to the state resulting from the execution of the given transaction.
  • trace β€” the basic trace of specific information.
    • action β€” the operation to be performed on the recipient.
      • from β€” the address initiating the transaction.
      • callType β€” the type of method, such as call or delegatecall.
      • gas β€” the units of gas supplied by the sender, encoded in hexadecimal format.
      • input β€” the data transmitted along with the transaction, typically used for interaction with smart contracts.
      • to β€” the recipient's address. If it's a contract creation transaction, this field is null.
      • value β€” the amount sent with the transaction, encoded as a hexadecimal.
    • result β€” the value of the gas price used, encoded as hexadecimal.
      • gasUsed β€” the total amount of gas used by all the transactions in the block, encoded as hexadecimal.
      • output β€” the return value from the contract call, encoded in hexadecimal. If the RETURN method isn't executed, the output will be empty bytes.
    • subtraces β€” a list of contract calls made by the transaction, each represented as a nested callframe object.
    • traceAddress β€” a list of addresses where the call was executed, the addresses of the parent calls, and the order of the current sub-call.
    • type β€” the value of the method, such as call or create.
  • vmTrace β€” a comprehensive trace of the virtual machine's state during the execution of a given transaction, including any sub-calls.
  • destroyedContracts β€” a list of the smart contract destroyed during the block execution; null if no contract was destroyed.

arbtrace_replayBlockTransactions code examples

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

// Define the arbtrace_get custom method
web3.extend({
    property: 'arbtrace',
    methods: [{
      name: 'replayBlockTransactions',
      call: 'arbtrace_replayBlockTransactions',
      params: 2,
    }],
  });
  
  async function replayBlockTransactions() {
    const block = "0x152dd46";
    const traceOptions = ["trace"];
  
    try {
      const result = await web3.arbtrace.replayBlockTransactions(block, traceOptions);
      console.log(result);
    } catch (error) {
      console.error("Error:", error);
    }
  }
  
  replayBlockTransactions();
const ethers = require('ethers');
const NODE_URL = "YOUR_CHAINSTACK_ENDPOINT";
const provider = new ethers.JsonRpcProvider(NODE_URL);

const arbtraceReplayBlockTransactions = async () => {
    const block = '0x152dd46'
    const tracer = 'trace';

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

arbtraceReplayBlockTransactions();
from web3 import Web3  
node_url = "YOUR_CHAINSTACK_ENDPOINT" 
web3 = Web3.HTTPProvider(node_url)

block = "0x152dd46";
traceOptions = ["trace"];

response = web3.provider.make_request('arbtrace_replayBlockTransactions', [transactionHash, traceOptions])
print(response)

Use case

The arbtrace_replayBlockTransactions allows you to replay the transactions within a specific block and retrieve detailed execution traces for each transaction. It is particularly useful for analyzing the state changes and interactions that occurred during the execution of transactions within a block.

Here are the key points to understand about the arbtrace_replayBlockTransactions method:

  • Retrieving execution traces β€” the method replays the transactions within a block and returns execution traces for each transaction. These traces provide a detailed account of the state changes, internal transactions, and events triggered during the execution.
  • Block-level analysis β€” the method focuses on a specific block and replays all the transactions within that block. It is different from individual transaction tracing methods, as it provides a comprehensive view of the interactions and effects of multiple transactions within a single block.
  • Contextual understanding β€” by using arbtrace_replayBlockTransactions, developers can gain a deeper understanding of the sequence and effects of transactions within a block. This can be valuable for debugging complex interactions, analyzing reentrancy issues, or understanding the overall impact of transactions on the blockchain state.

Try the arbtrace_replayBlockTransactions RPC method yourself

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