curl --request POST \
--url https://hyperliquid-mainnet.core.chainstack.com/4f8d8f4040bdacd1577bff8058438274/evm \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc": "2.0",
"method": "debug_traceTransaction",
"params": [
"0x07712544ce8f50091c6c3b227921f763b342bf9465a22f0226d651a3246adb31",
{
"tracer": "callTracer"
}
],
"id": 1
}'
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"type": "CALL",
"from": "0x...",
"to": "0x...",
"value": "0x0",
"gas": "0x...",
"gasUsed": "0x...",
"input": "0x...",
"output": "0x..."
}
}
Returns detailed trace information for a specific transaction. This method provides comprehensive debugging information including call traces, state changes, and execution details.
curl --request POST \
--url https://hyperliquid-mainnet.core.chainstack.com/4f8d8f4040bdacd1577bff8058438274/evm \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc": "2.0",
"method": "debug_traceTransaction",
"params": [
"0x07712544ce8f50091c6c3b227921f763b342bf9465a22f0226d651a3246adb31",
{
"tracer": "callTracer"
}
],
"id": 1
}'
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"type": "CALL",
"from": "0x...",
"to": "0x...",
"value": "0x0",
"gas": "0x...",
"gasUsed": "0x...",
"input": "0x...",
"output": "0x..."
}
}
debug_traceTransaction
JSON-RPC method returns detailed trace information for a specific transaction. This method provides comprehensive debugging information including call traces, gas usage, state changes, and execution details, making it essential for transaction analysis, debugging, and forensic investigations.
tracer
(string): The type of tracer to use. Common options include:
"callTracer"
: Provides detailed call trace information"prestateTracer"
: Shows state before transaction execution"4byteTracer"
: Tracks function selector usagetype
— The type of call (CALL, DELEGATECALL, STATICCALL, CREATE, etc.)from
— The address that initiated the callto
— The address that received the callvalue
— The value transferred in the callgas
— The amount of gas allocated for the callgasUsed
— The amount of gas actually consumedinput
— The input data for the calloutput
— The output data returned by the callcalls
— Array of sub-calls made during execution// Trace a specific transaction
const traceTransaction = async (txHash) => {
const response = await fetch('https://hyperliquid-mainnet.core.chainstack.com/YOUR_ENDPOINT/evm', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
jsonrpc: '2.0',
method: 'debug_traceTransaction',
params: [
txHash,
{
tracer: 'callTracer'
}
],
id: 1
})
});
const data = await response.json();
return data.result;
};
// Analyze transaction execution
const analyzeTransaction = async (txHash) => {
try {
const trace = await traceTransaction(txHash);
console.log('Transaction Trace Analysis:');
console.log(`Type: ${trace.type}`);
console.log(`From: ${trace.from}`);
console.log(`To: ${trace.to}`);
console.log(`Value: ${parseInt(trace.value, 16)} wei`);
console.log(`Gas Used: ${parseInt(trace.gasUsed, 16)}`);
// Analyze sub-calls
if (trace.calls && trace.calls.length > 0) {
console.log(`\nSub-calls (${trace.calls.length}):`);
trace.calls.forEach((call, index) => {
console.log(` ${index + 1}. ${call.type}: ${call.from} -> ${call.to}`);
console.log(` Gas Used: ${parseInt(call.gasUsed, 16)}`);
});
}
return trace;
} catch (error) {
console.error('Error tracing transaction:', error);
throw error;
}
};
// Gas usage analysis
const analyzeGasUsage = (trace) => {
const totalGas = parseInt(trace.gas, 16);
const gasUsed = parseInt(trace.gasUsed, 16);
const efficiency = ((gasUsed / totalGas) * 100).toFixed(2);
console.log('Gas Analysis:');
console.log(`Total Gas Limit: ${totalGas.toLocaleString()}`);
console.log(`Gas Used: ${gasUsed.toLocaleString()}`);
console.log(`Efficiency: ${efficiency}%`);
return {
totalGas,
gasUsed,
efficiency: parseFloat(efficiency)
};
};
// Usage
const txHash = '0x07712544ce8f50091c6c3b227921f763b342bf9465a22f0226d651a3246adb31';
analyzeTransaction(txHash).then(trace => {
analyzeGasUsage(trace);
});
curl -X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "debug_traceTransaction",
"params": [
"0x07712544ce8f50091c6c3b227921f763b342bf9465a22f0226d651a3246adb31",
{
"tracer": "callTracer"
}
],
"id": 1
}' \
https://hyperliquid-mainnet.core.chainstack.com/4f8d8f4040bdacd1577bff8058438274/evm
debug_traceTransaction
method is essential for applications that need to:
Successful response with transaction trace data
The response is of type object
.
Was this page helpful?