This repository serves to provide a fairly basic demonstration of running @truffle/debugger against a transaction and reading the corresponding txlog.
-
First clone this repository and install its dependencies:
git clone git@github.com:trufflesuite/txlog-demo.git cd txlog-demo yarn
-
Then, run
ts-node
:npx ts-node
-
Inside ts-node, import the provided behavior:
import { getTxlog, emittedFlattedEvents, printFlattedEvents } from "./src";
-
Invoke
getTxlog
and capture the result to a variable. Listed here are the provided default values, but you will likely want to override these:const txlog = await getTxlog({ txHash: "0x2c86c8ab611b7fcfeb1849aa0ab5ddbb61a357941b8d31c605fb02fdd6c61bb4", rpcUrl: process.env.MAINNET_URL, etherscanKey: process.env.ETHERSCAN_KEY });
This step runs @truffle/fetch-and-compile to obtain verified sources on Etherscan, invokes solc, and runs the debugger to the end. This may take a while and/or may produce warnings during compilation.
-
Use
emittedFlattedEvents
to see only those events that were actually emitted (i.e., not part of a reverted call):emittedFlattedEvents(txlog);
-
Use
printFlattedEvents()
to produce a human-friendly display of the events emitted as part of the transaction:printFlattedEvents(txlog);