Skip to content

edycutjong/NansenRedString

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

35 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ”ด RedString โ€” On-Chain Forensic Investigation Engine

    ____          __  _____ __       _             
   / __ \___  ____/ / / ___// /______(_)___  ____  
  / /_/ / _ \/ __  /  \__ \/ __/ ___/ / __ \/ __ `/
 / _, _/  __/ /_/ /  ___/ / /_/ /  / / / / / /_/ / 
/_/ |_|\___/\__,_/  /____/\__/_/  /_/_/ /_/\__, /  
                                          /____/   

CI TypeScript Node.js License: MIT

Map wallet networks as interactive 3D graphs. RedString is a forensic investigation CLI that wraps the Nansen CLI to perform BFS traversal of on-chain wallet connections, enrich nodes with financial intelligence, and render self-contained WebGL visualizations.

Built for the Nansen CLI Build Challenge โ€” Week 4


๐ŸŽฌ Demo

RedString Demo


โœจ Features

  • ๐Ÿ•ต๏ธ BFS Graph Traversal โ€” Discover wallet networks with configurable depth (1โ€“3) and width (5โ€“20)
  • ๐Ÿ’ฐ Financial Enrichment โ€” Labels, balances, 30d PnL, DeFi protocol exposure per node
  • ๐ŸŒ 3D WebGL Visualization โ€” Self-contained HTML with auto-orbit cameras, particle effects, and screenshot export
  • ๐Ÿ” OSINT Integration โ€” Off-chain intelligence via Nansen web search
  • โšก Disk Cache โ€” SHA256-keyed persistent cache to minimize API costs (configurable TTLs)
  • ๐Ÿ“Š Telemetry Receipt โ€” Forensic audit trail of every API call with latency tracking
  • ๐ŸŽญ Mock Mode โ€” Full offline development with synthetic data (NANSEN_MOCK=true)

๐Ÿ—๏ธ Architecture

redstring investigate 0xdead... --depth 2 --width 10
        โ”‚
        โ”œโ”€โ”€โ”€ BFS Engine (graph-builder.ts)
        โ”‚    โ”œโ”€โ”€ profiler trace โ†’ connections
        โ”‚    โ”œโ”€โ”€ profiler counterparties โ†’ fallback
        โ”‚    โ””โ”€โ”€ enrichNode โ†’ labels, balance, PnL, DeFi
        โ”‚
        โ”œโ”€โ”€โ”€ OSINT Layer (osint.ts)
        โ”‚    โ””โ”€โ”€ web search โ†’ off-chain intelligence
        โ”‚
        โ”œโ”€โ”€โ”€ Terminal Report (terminal-report.ts)
        โ”‚    โ””โ”€โ”€ Palantir-aesthetic forensic summary
        โ”‚
        โ”œโ”€โ”€โ”€ HTML Renderer (html-renderer.ts)
        โ”‚    โ””โ”€โ”€ 3D force-directed graph (3d-force-graph)
        โ”‚
        โ””โ”€โ”€โ”€ Telemetry (telemetry.ts)
             โ””โ”€โ”€ API call receipt with cache hit rates

๐Ÿš€ Quick Start

Prerequisites

  • Node.js โ‰ฅ 18
  • Nansen CLI installed and authenticated (npm i -g @nansen/cli)

Install & Run

# Clone
git clone https://github.com/edycutjong/nansen-redstring.git
cd nansen-redstring

# Install dependencies
npm install

# Run in mock mode (no API key needed)
NANSEN_MOCK=true npx tsx src/index.ts investigate 0xdead...beef

# Run with live Nansen API
npx tsx src/index.ts investigate 0xdead...beef --depth 2 --width 10

Global Install

npm run build
npm link
redstring investigate 0xdead...beef

๐Ÿ“– Commands

investigate <address>

Core forensic command. Traces wallet connections via BFS and renders a 3D graph.

Flag Description Default
-d, --depth <n> BFS traversal depth (1โ€“3) 2
-w, --width <n> Max counterparties per node (5โ€“20) 10
-c, --chain <chain> Blockchain network ethereum
-m, --min-volume <usd> Minimum USD volume filter 0
--osint Include off-chain web search false
--no-cache Bypass disk cache false
--no-open Skip auto-opening browser false
--json Output raw graph JSON false
-o, --output <dir> Output directory for HTML cwd

Investigate Command

compare <address-a> <address-b>

Head-to-head wallet comparison. Shows correlation score, common counterparties, and shared tokens.

Flag Description Default
-c, --chain <chain> Blockchain network ethereum
--json Output raw JSON false

Compare Command

profile <address>

Deep wallet profile โ€” labels, balance, PnL, DeFi positions, and recent transactions.

Flag Description Default
-c, --chain <chain> Blockchain network ethereum
--json Output raw JSON false

Profile Command

๐ŸŽฎ 3D Visualizer Controls

Shortcut Action
S Screenshot (PNG export)
R Reset camera position
L Toggle node labels
Mouse drag Rotate view
Scroll Zoom in/out
Click node Open detail panel

Node Color Legend

Color Meaning
๐Ÿ”ด Neon Crimson Seed / Target wallet
๐ŸŸก Cyber Gold Smart Money
๐Ÿ”ต Neon Cyan Labeled entity (Exchange, DEX, etc.)
โšซ Dim Slate Unknown wallet
๐Ÿ”˜ Muted Gray Contract

๐Ÿ“ธ Gallery


Investigate

Profile

Compare

Compare (Full)

Telemetry Receipt

๐Ÿงช Development

# Type check
npm run typecheck

# Lint
npm run lint

# Run tests
npm test

# Run tests with coverage
npm run test:coverage

# Full CI pipeline (typecheck + lint + test:coverage)
npm run ci

Demo Cast (Suggested Wallets)

Alias Address Why
jaredfromsubway.eth 0xae2Fc483527B8EF99EB5D9B44875F005ba1FaE13 MEV bot operator
Wintermute 0x0000000000000000000000000000000000000000 Market maker
Nomad Exploiter 0x56D8B635A7C88Fd1104D23d632AF4003B16d0BF6 Bridge exploit

๐Ÿ”ง Environment Variables

Variable Description
NANSEN_MOCK Enable synthetic data mode (true/false)
NANSEN_DEBUG Enable verbose API error logging (true/false)

๐Ÿ“ Project Structure

src/
โ”œโ”€โ”€ index.ts              # CLI entry point (Commander.js)
โ”œโ”€โ”€ commands/
โ”‚   โ”œโ”€โ”€ investigate.ts    # BFS investigation command
โ”‚   โ”œโ”€โ”€ compare.ts        # Wallet comparison command
โ”‚   โ””โ”€โ”€ profile.ts        # Deep wallet profile command
โ”œโ”€โ”€ lib/
โ”‚   โ”œโ”€โ”€ graph-builder.ts  # BFS traversal engine
โ”‚   โ”œโ”€โ”€ nansen.ts         # Nansen CLI wrapper + caching
โ”‚   โ”œโ”€โ”€ html-renderer.ts  # 3D WebGL HTML generator
โ”‚   โ”œโ”€โ”€ enricher.ts       # Node financial enrichment
โ”‚   โ”œโ”€โ”€ osint.ts          # Off-chain intelligence
โ”‚   โ”œโ”€โ”€ disk-cache.ts     # SHA256-keyed persistent cache
โ”‚   โ”œโ”€โ”€ telemetry.ts      # API call tracking
โ”‚   โ”œโ”€โ”€ terminal-report.ts # Terminal formatting
โ”‚   โ””โ”€โ”€ mock.ts           # Synthetic data generator
โ””โ”€โ”€ types/
    โ”œโ”€โ”€ graph.ts          # GraphNode, GraphEdge, GraphData
    โ”œโ”€โ”€ investigation.ts  # InvestigationOptions, results
    โ””โ”€โ”€ wallet.ts         # Raw API response shapes

๐Ÿ“„ License

MIT ยฉ edycutjong

About

๐Ÿ”ด On-chain forensic investigation engine โ€” BFS wallet graph traversal, financial enrichment, and interactive 3D WebGL visualization. Built on Nansen CLI.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors