debug_traceTransaction
Traces a transaction execution on XDC Network by transaction hash.
Archive Node Required
This method requires an archive node. It is not available on full nodes.
Use Cases#
- Transaction debugging - Understand exactly what happened
- Failure analysis - Find where and why a transaction reverted
- Gas optimization - Analyze gas usage for tokenized trade finance (Letters of Credit, Bills of Lading), cross-border payments, and real-world asset tokenization
Parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
txHash | DATA | Yes | 32-byte transaction hash |
tracerConfig | Object | No | Tracer configuration |
Tracer Options#
{}- Default opcode tracer (verbose){ tracer: "callTracer" }- Call tree tracer{ tracer: "prestateTracer" }- Pre-state tracer
Request#
{
"jsonrpc": "2.0",
"method": "debug_traceTransaction",
"params": ["", {"tracer": "callTracer"}],
"id": 1
}
Code Examples#
- cURL
- JavaScript
- Python
curl -X POST https://api-xdc-mainnet.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "debug_traceTransaction",
"params": ["", {"tracer": "callTracer"}],
"id": 1
}'
import { JsonRpcProvider } from 'ethers';
const provider = new JsonRpcProvider('https://api-xdc-mainnet.n.dwellir.com/YOUR_API_KEY');
const txHash = '';
// Call tracer - shows internal calls
const callTrace = await provider.send('debug_traceTransaction', [
txHash,
{ tracer: 'callTracer' }
]);
console.log('Type:', callTrace.type);
console.log('From:', callTrace.from);
console.log('To:', callTrace.to);
console.log('Gas used:', parseInt(callTrace.gasUsed, 16));
// Prestate tracer - shows state before execution
const prestateTrace = await provider.send('debug_traceTransaction', [
txHash,
{ tracer: 'prestateTracer' }
]);
from web3 import Web3
w3 = Web3(Web3.HTTPProvider('https://api-xdc-mainnet.n.dwellir.com/YOUR_API_KEY'))
tx_hash = ''
# Call tracer
trace = w3.provider.make_request('debug_traceTransaction', [
tx_hash,
{'tracer': 'callTracer'}
])
print(f'Trace type: {trace["result"]["type"]}')
print(f'Gas used: {int(trace["result"]["gasUsed"], 16)}')
Related Methods#
debug_traceCall- Trace without executingdebug_traceBlockByNumber- Trace entire block