trace_replayTransaction
Replays a transaction on Ethereum and returns the requested traces.
Archive Node Required
This method requires an archive node. It is not available on full nodes.
Use Cases#
- Transaction replay - Re-execute a transaction with full trace output
- State diff extraction - Get exact state changes from a transaction
- VM trace debugging - Get opcode-level execution details for DeFi protocols (60% market share), NFT marketplaces, DAOs, and enterprise dApps
Parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
txHash | DATA | Yes | 32-byte transaction hash |
traceTypes | Array | Yes | Trace types: ["trace"], ["vmTrace"], ["stateDiff"], or combinations |
Request#
{
"jsonrpc": "2.0",
"method": "trace_replayTransaction",
"params": ["0x42690cc81dfd7f6a5ebc973fd8c4912e6068df47646c665a1b54fae904b0470a", ["trace"]],
"id": 1
}
Code Examples#
- cURL
- JavaScript
- Python
curl -X POST https://api-ethereum-mainnet.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "trace_replayTransaction",
"params": ["0x42690cc81dfd7f6a5ebc973fd8c4912e6068df47646c665a1b54fae904b0470a", ["trace"]],
"id": 1
}'
import { JsonRpcProvider } from 'ethers';
const provider = new JsonRpcProvider('https://api-ethereum-mainnet.n.dwellir.com/YOUR_API_KEY');
const result = await provider.send('trace_replayTransaction', [
'0x42690cc81dfd7f6a5ebc973fd8c4912e6068df47646c665a1b54fae904b0470a',
['trace']
]);
console.log('Trace:', result.trace.length, 'entries');
console.log('State diff:', result.stateDiff ? 'present' : 'not requested');
from web3 import Web3
w3 = Web3(Web3.HTTPProvider('https://api-ethereum-mainnet.n.dwellir.com/YOUR_API_KEY'))
result = w3.provider.make_request('trace_replayTransaction', [
'0x42690cc81dfd7f6a5ebc973fd8c4912e6068df47646c665a1b54fae904b0470a',
['trace']
])
trace = result['result']
print(f'Trace entries: {len(trace["trace"])}')
Related Methods#
trace_replayBlockTransactions- Replay all transactions in a blocktrace_transaction- Get traces without replaytrace_block- Get all traces in a block