Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

trufflesuite/txlog-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

txlog-demo

This repository serves to provide a fairly basic demonstration of running @truffle/debugger against a transaction and reading the corresponding txlog.

Usage

  1. First clone this repository and install its dependencies:

    git clone git@github.com:trufflesuite/txlog-demo.git
    cd txlog-demo
    yarn
  2. Then, run ts-node:

    npx ts-node
  3. Inside ts-node, import the provided behavior:

    import { getTxlog, emittedFlattedEvents, printFlattedEvents } from "./src";
  4. 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.

  5. Use emittedFlattedEvents to see only those events that were actually emitted (i.e., not part of a reverted call):

    emittedFlattedEvents(txlog);
  6. Use printFlattedEvents() to produce a human-friendly display of the events emitted as part of the transaction:

    printFlattedEvents(txlog);
See example usage with output Screen Shot 2022-09-08 at 6 27 23 PM

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published