curl --request POST \
--url https://rpc.testnet.tempo.xyz/ \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"method": "trace_block",
"params": [
"latest"
],
"id": 1
}
'{
"jsonrpc": "<string>",
"id": 123,
"result": [
{}
]
}curl --request POST \
--url https://rpc.testnet.tempo.xyz/ \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"method": "trace_block",
"params": [
"latest"
],
"id": 1
}
'{
"jsonrpc": "<string>",
"id": 123,
"result": [
{}
]
}blockParameter — the block number (hex) or tag (latest, earliest, pending)result — array of trace objects for all transactions in the block:
action — the action object:
from — sender addressto — recipient addresscallType — type of call (call, delegatecall, staticcall, etc.)gas — gas providedinput — call datavalue — value transferredblockHash — hash of the blockblockNumber — block numberresult — the result object:
gasUsed — gas consumedoutput — return datasubtraces — number of child tracestraceAddress — position in the trace treetransactionHash — hash of the transactiontransactionPosition — index of the transaction in the blocktype — trace type (call, create, suicide, reward)trace_block code examplesconst ethers = require('ethers');
const NODE_URL = "CHAINSTACK_NODE_URL";
const provider = new ethers.JsonRpcProvider(NODE_URL);
const traceBlock = async (blockNumber) => {
const traces = await provider.send("trace_block", [blockNumber]);
console.log(`Block has ${traces.length} traces`);
// Group traces by transaction
const txTraces = {};
for (const trace of traces) {
const txHash = trace.transactionHash;
if (!txTraces[txHash]) {
txTraces[txHash] = [];
}
txTraces[txHash].push(trace);
}
console.log(`Across ${Object.keys(txTraces).length} transactions`);
for (const [txHash, txTrace] of Object.entries(txTraces)) {
console.log(`\nTx: ${txHash}`);
for (const trace of txTrace) {
const indent = " ".repeat(trace.traceAddress.length);
console.log(`${indent}${trace.action.callType}: ${trace.action.from} -> ${trace.action.to}`);
}
}
};
traceBlock("latest");
Was this page helpful?