Arbitrum API method that returns the traces of a transaction based on its traces position. The index positions of the traces within a transaction refer to the individual steps or actions that occurred during the execution of that transaction. Each trace represents a specific operation or event within the transaction, such as a contract function call or a state change.
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_get
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 transaction hash for which you want to retrieve the trace. It is a unique identifier for the transaction.array
— an array of index positions representing the traces within the transaction that you want to retrieve. The index positions indicate the specific steps or actions within the transaction.
Response
result
— an object containing the traces of all of the transaction:action
— an object that describes the action taken by the transaction:calltype
— the type of call,call
ordelegatecall
, 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.from
— the address that initiated the action.gas
— the amount of gas allocated for the action.input
— the input data provided for the action.to
— the address of the contract or account receiving the action.value
— the value in Wei sent along with the action.
blockhash
— the hash of the block where the action was included.blocknumber
— the number of the block where the action was included.result
— an object that contains additional data about the execution of the transaction:gasused
— the amount of gas used during the action.output
— the output data returned by the action.
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 representing the path to the current action within the trace.transactionhash
— the hash of the transaction associated with the trace.transactionposition
— the position of the transaction within the block.type
— the type of action taken by the transaction,call
orcreate
.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_get
code examples
arbtrace_get
code examplesconst 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: 'get',
call: 'arbtrace_get',
params: 2,
}],
});
async function arbtraceGet() {
const transactionHash = "0xe8648e3ad982a3d67ef0880d6631343cffff364786994b34e5fa292cfef0e680";
const traceOptions = ["0x0"];
try {
const result = await web3.arbtrace.get(traceHash, traceOptions);
console.log(result);
} catch (error) {
console.error("Error:", error);
}
}
arbtraceGet();
const ethers = require('ethers');
const NODE_URL = "YOUR_CHAINSTACK_ENDPOINT";
const provider = new ethers.JsonRpcProvider(NODE_URL);
const arbtraceGet = async () => {
const transactionHash = "0xe8648e3ad982a3d67ef0880d6631343cffff364786994b34e5fa292cfef0e680";
const traceOptions = ["0x0"];
const traces = await provider.send("arbtrace_get", [transactionHash, traceOptions]);
console.log(traces);
};
arbtraceGet();
from web3 import Web3
node_url = "YOUR_CHAINSTACK_ENDPOINT"
web3 = Web3.HTTPProvider(node_url)
transactionHash = "0xe8648e3ad982a3d67ef0880d6631343cffff364786994b34e5fa292cfef0e680";
traceOptions = ["0x0"];
response = web3.provider.make_request('arbtrace_get', [transactionHash, traceOptions])
print(response)
Use case
The arbtrace_get
method is valuable for transaction analysis and debugging on the Arbitrum blockchain. By retrieving a detailed trace of a specific transaction, you can gain insights into the sequence of actions and their outcomes. Practical use cases include:
- Debugging smart contract transactions — analyzing the trace helps identify issues and unexpected behavior by examining the specific function calls, parameters, and values involved.
- Identifying execution errors — the trace provides information on where errors occurred within the transaction, helping pinpoint the cause of failures or issues. Gas consumption and output data can also be examined for error messages.
- Gas usage optimization — by analyzing the
gasUsed
field in the trace's result, you can identify gas-intensive operations and optimize gas usage in your smart contract code. - Auditing and security analysis — the
arbtrace_get
method enables thorough audits of smart contract transactions. Analyzing the trace ensures that the transaction aligns with expected behavior, state changes, and security requirements.
Try the arbtrace_get
RPC method yourself
arbtrace_get
RPC method yourself