npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

fork-trace

v1.0.1

Published

Replay Ethereum mainnet transactions using Anvil with AI-powered analysis

Readme


✨ Features

  • One-command replay of any main-net transaction on a local Anvil fork.
  • Modify on the fly (--mod '{"value":"0"}') to test hypotheses.
  • AI-powered analysis (Ollama + open-source LLM of your choice)
  • Automatic failure root-cause detection & revert-string decoding.
  • State-diff visualisation (balances, nonces, code changes).
  • Exports to json, md, and transaction trace files.
  • Snapshot / restore of forked chain state.
  • Zero-config—works out of the box with a free Etherscan key.

🏗️ Architecture

                                +-----------------------------+
fork-trace CLI  -------------> |   Orchestrator (index.js)   |
                                +-------------+---------------+
                                              |
        +--------------------------+----------+--------------------------+
        |                          |                                     |
+-------v--------+       +---------v--------+               +------------v-----------+
|  Tx Fetcher    |       |  Anvil Forker    |               |   Transaction Replayer |
| (Etherscan)    |       | (Foundry Anvil)  |               |                        |
+----------------+       +------------------+               +------------------------+
                                              |
                                +-------------v-------------+
                                | State Analyzer / Diff Gen |
                                +-------------+-------------+
                                              |
        +--------------------------+----------+--------------------------+
        |                          |                                     |
+-------v--------+       +---------v--------+               +------------v-----------+
| AI Explainer   |       | Exporter (md/JSON)|              |  Snapshot Manager      |
| (Ollama + LLM) |       +-------------------+              +------------------------+
+----------------+

⚒️ Installation

1. Clone & Install

git clone https://github.com/techyarnav/ForkTrace.git
cd ForkTrace
npm install

2. Install Anvil (Foundry)

curl -L https://foundry.paradigm.xyz | bash
foundryup # makes anvil available in $PATH

3. Install Ollama & Pull a Model (optional but recommended)

brew install ollama                                         # for macOS

curl -fsSL https://ollama.com/install.sh | sh               # for Linux

iwr https://ollama.com/install.ps1 -UseBasicParsing | iex   # for Windows (via PowerShell):
ollama serve & # starts the local LLM server

ollama pull qwen2.5-coder:7b # high-quality code-oriented model

ollama pull tinyllama:chat 

ollama pull deepseek-coder:6.7b 

ollama pull codellama:13b 

ollama pull wizardcoder:13b 

ollama pull phi3:mini  

4. Set your Etherscan API key

export ETHERSCAN_API_KEY="YourRealKeyHere"

🚀 Usage

fork-trace --help
Usage: fork-trace [options] <txHash>

Replay Ethereum mainnet transactions using Anvil with AI-powered analysis

Arguments:
  txHash               Ethereum transaction hash to replay

Options:
  -V, --version        output the version number
  --anvil-port <port>  port for Anvil instance (default: 8545)
  --mod <json>         modify transaction fields (JSON)
  --ai                 enable AI-powered transaction analysis (requires ollama)
  --ai-endpoint <url>  AI service endpoint (default: "http://localhost:11434")
  --ai-model <name>    AI model name (default: "tinyllama:chat")
  --export <formats>   export formats (comma-separated): json,md,trace,all
  --output-dir <dir>   export directory (default: "./exports")
  --save-state <name>  save Anvil state snapshot with this name
  --state-dir <dir>    directory for state snapshots (default: "./anvil-states")
  --no-color           disable colored output
  -h, --help           display help for command

Examples:
  $ fork-trace 0x1234...abcd
  $ fork-trace 0x1234...abcd --export json,md
  $ fork-trace 0x1234...abcd --ai --export all
  $ fork-trace 0x1234...abcd --mod '{"value":"0"}' --save-state before-mod
  $ fork-trace 0x1234...abcd --anvil-port 8546 --output-dir ./reports
  
Prerequisites:
  - Anvil (from Foundry toolkit)
  - Etherscan API key in environment: ETHERSCAN_API_KEY
  - Ollama running locally (optional, for AI analysis)
  1. Simple replay
fork-trace 0x88df0164... --anvil-port 8555
  1. Modify value to 0 and export JSON
fork-trace 0x88df0164... --mod '{"value":"0"}' --export json
  1. AI analysis with Qwen 7 B model
fork-trace 0x88df0164... --ai --ai-model "qwen2.5-coder:7b"
  1. Save state snapshot
fork-trace 0x88df0164... --save-state

fork-trace 0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b \
  --ai --ai-model "qwen2.5-coder:7b" \
  --export json,md \
  --save-state full-test-clean \
  --anvil-port 8561

Common flags:

| Flag | Description | |------|-------------| | --mod <json> | Override any tx field (value, data, gasPrice …) | | --ai | Enable AI analysis (needs Ollama running) | | --ai-model <name> | Pick an Ollama model (default tinyllama:chat) | | --export <fmt> | Comma-sep list: json,md,trace,all | | --save-state <name> | Dump a snapshot of the forked chain | | --anvil-port <p> | Run Anvil on a custom port |


🧰 Tech Stack

| Layer | Library / Tool | |-------|----------------| | CLI / args | commander, chalk | | Ethereum provider | ethers.js v6 | | Forked chain | Anvil (Foundry) | | AI | Ollama + open-source LLM (TinyLlama, Qwen, DeepSeek R1 …) | | HTTP | axios | | Bundler | Node 20+ (ESM/TS ready) |


🤝 Contributing - We welcome contributions! Please see our Contributing Guide for details.

  • Fork the repository

  • Create your feature branch (git checkout -b feature/amazing-feature)

  • Commit your changes (git commit -m 'Add features')

  • Push to the branch (git push origin feature/amazing-feature)

  • Open a Pull Request

📄 License

This project is licensed under the MIT License — see the LICENSE file for details.