arbtrace_transaction | Arbitrum

Arbitrum API method that traces a specific transaction. It provides a detailed record of all the steps taken by the Ethereum Virtual Machine (EVM) during the execution, including all the operations performed and the changes made to the blockchain state.

📘

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

👍

Get you own node endpoint today

Start for free and get your app to production levels immediately. No credit card required.

You can sign up with your GitHub, X, Google, or Microsoft account.

Parameters

  • hash — the hash identifying a transaction

Response

  • 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_transaction code examples

const Web3 = require("web3"); const NODE_URL = "YOUR_CHAINSTACK_ENDPOINT"; const web3 = new Web3(NODE_URL); // Define the arbtrace_transaction custom method web3.extend({ property: 'debug', methods: [{ name: 'traceTransaction', call: 'arbtrace_transaction', params: 1, inputFormatter: [web3.extend.formatters.inputHashFormatter], outputFormatter: web3.extend.formatters.outputCallFormatter }] }); async function traceTransaction(txHash) { const result = await web3.debug.traceTransaction(txHash); console.log(result); } traceTransaction("0xe8648e3ad982a3d67ef0880d6631343cffff364786994b34e5fa292cfef0e680");
const ethers = require('ethers'); const NODE_URL = "YOUR_CHAINSTACK_ENDPOINT"; const provider = new ethers.JsonRpcProvider(NODE_URL); const traceTransaction = async (txHash) => { const traces = await provider.send("arbtrace_transaction", [txHash]); console.log(traces); }; traceTransaction("0xe8648e3ad982a3d67ef0880d6631343cffff364786994b34e5fa292cfef0e680")
from web3 import Web3 node_url = "YOUR_CHAINSTACK_ENDPOINT" web3 = Web3.HTTPProvider(node_url) tx_hash = "0xe8648e3ad982a3d67ef0880d6631343cffff364786994b34e5fa292cfef0e680" traces = web3.provider.make_request('arbtrace_transaction', [tx_hash]) print(traces)

Use case

The arbtrace_transaction method in Arbitrum is useful for debugging and analyzing transactions on the blockchain. It allows developers to trace the execution of a specific transaction and retrieve detailed information about its steps, contract calls, state changes, and gas consumption.

Analyzing the trace helps developers identify the specific step or contract interaction where the issue occurs. With this information, they can debug and resolve the problem, whether it's a logical error, incorrect input values, or unexpected interactions with other contracts.

Try the arbtrace_transaction RPC method yourself

Body Params
integer
Defaults to 1
string
Defaults to 2.0
string
Defaults to arbtrace_transaction
array
Defaults to 0xe8648e3ad982a3d67ef0880d6631343cffff364786994b34e5fa292cfef0e680
params
Response

Language
Click Try It! to start a request and see the response here! Or choose an example:
application/json