UNPKG

mev-inspect

Version:

A JS port of 'mev-inspect-py' optimised for ease of use.

41 lines 1.24 kB
async function getTransactionTrace(provider, hash) { const response = (await provider.send('trace_replayTransaction', [ hash, ['trace'], ])); return parseTrace(response); } async function getBlockTraces(provider, block) { const response = (await provider.send('trace_replayBlockTransactions', [ block, ['trace'], ])); for (const trace of response) { if (!trace.trace) { return null; } } return Object.fromEntries(response.map((replay) => { return [replay.transactionHash, parseTrace(replay)]; })); } function parseTrace(replay) { return { calls: replay.trace .filter((trace) => trace.type === 'call' && 'result' in trace) .map((trace) => { const { action, result } = trace; return { from: action.from, to: action.to, input: action.input, output: result.output, value: BigInt(action.value), gas: BigInt(action.gas), gasUsed: BigInt(result.gasUsed), }; }), }; } export { getBlockTraces, getTransactionTrace }; //# sourceMappingURL=traces.js.map