BrianBland/basescope

TUI for visualizing transaction patterns against base fees on Base

โ˜… 1Forks 0RustGitHub โ†—Compare

README

basescope ๐Ÿ”ฌ

A terminal UI for analyzing transaction activity on Base. Fetches blocks over JSON-RPC, matches transactions against user-defined filters (by sender, recipient, or both), and renders live charts showing tx counts, base fee trends, and fee distribution histograms.

basescope screenshot

Features

  • Filter-based tx scanning โ€” define filters like to:0x..., from:0x..., or addr:0x... with optional labels
  • Live-updating charts โ€” tx count, gas usage, and tx size per block; base fee / gas / bytes over time; and distribution histograms update as blocks stream in
  • Chart type switching โ€” press t to cycle between tx count, gas used, and tx size (RLP-encoded bytes) views across all charts
  • Color-coded overlays โ€” each filter gets a distinct color across all charts; overlapping regions blend automatically
  • Aggregate mode โ€” toggle to union all filter matches into a single series
  • Zoom & pan โ€” scroll wheel or z/Z to zoom into block ranges; horizontal scroll or arrow keys to pan; Home to reset
  • Mouse crosshair โ€” hover over charts to inspect individual block values
  • Chunk-level caching โ€” fetched block data is cached to disk as bincode, so re-scanning the same range is instant
  • Multi-RPC support โ€” round-robin across multiple endpoints with automatic scoring/failover
  • Adjustable granularity โ€” group blocks in buckets of 1 to 10000+, with auto-scaling based on block range; affects both line charts and histograms

Install

cargo install --path .

Or build from source:

cargo build --release

Chart export (PNG/SVG screenshots via e key) is enabled by default. To build without it:

cargo build --release --no-default-features

Usage

Interactive

basescope

The TUI walks you through entering a block range and adding filters. Filters use the format:

label=to:0xADDRESS
label=from:0xADDRESS
label=addr:0xADDRESS

The label is optional โ€” if omitted, the filter expression itself is used.

CLI

Skip the input screens by passing everything up front:

basescope \
  --start-block 42000000 \
  --end-block 42010000 \
  --filter "uniswap=to:0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD" \
  --filter "from:0x000000000000000000000000000000000000dEaD"

Configuration

All CLI flags can be set via environment variables or a .env file:

Variable Default Description
BASESCOPE_RPC_URLS https://mainnet.base.org Comma-separated RPC endpoints
BASESCOPE_DATA_DIR ./data Where cached block data is stored
BASESCOPE_CONCURRENCY 10 Max concurrent RPC requests
BASESCOPE_START_BLOCK โ€” Start of block range
BASESCOPE_END_BLOCK โ€” End of block range

Keybindings

Key Action
1โ€“9 Toggle individual filters on/off
a Toggle aggregate mode
g Cycle granularity (1 โ†’ 10 โ†’ 100 โ†’ 1000 โ†’ auto โ†’ 1)
G Set custom granularity (number or "auto")
h Cycle histogram mode (filter matches โ†’ all blocks โ†’ stacked)
s Cycle base fee Y-axis scale (linear โ†’ log โ†’ sqrt)
t Cycle chart type (tx count โ†’ gas used โ†’ tx size)
m Cycle EMA trendlines on top chart (20 โ†’ 50 โ†’ 250 โ†’ off)
l Toggle log panel
r Toggle RPC info panel
c / click Copy hovered block number to clipboard
e Export chart to PNG/SVG (requires export feature)
z / Z Zoom in / out (centered on cursor)
โ† / โ†’ Pan left / right when zoomed
Home Reset zoom to full range
q Quit

Mouse movement over the top two charts shows a crosshair with block number and values. Click or press c to copy the block number to the clipboard. Vertical scroll zooms; horizontal scroll pans.

Testing

cargo test

Unit tests cover domain logic (timestamp/block conversion, filter parsing, chunk ranges), rendering helpers (fee formatting, series grouping, axis labels), and TUI utilities (auto-granularity, scale mode roundtrips).

Architecture

main.rs           CLI parsing, terminal setup
domain.rs         Core types (filters, blocks, chunks, snapshots)
rpc/              Alloy-based JSON-RPC client with multi-endpoint scoring
cache/            Bincode chunk cache on disk
pipeline/         Concurrent block fetching with progress events
analysis/         Incremental filter matching and histogram computation
tui/              Ratatui app loop, event handling, rendering

License

The Unlicense โ€” public domain.

Contributors

BrianBland

Issues