Skip to main content

A lightweight EVM blockchain indexer and explorer

Project description

LocalScan

A lightweight EVM blockchain indexer and explorer. LocalScan connects to any EVM-compatible node via WebSocket or HTTP, indexes blocks and transactions in real time into a local SQLite database, and exposes a web UI alongside a REST API for querying chain data.

Features

  • Real-time block indexing via WebSocket (eth_subscribe) or HTTP polling — use whatever your node supports
  • ERC-20 transfer log tracking and token balance caching
  • Address, contract, and token metadata resolution
  • Web-based block explorer UI
  • REST API for blocks, transactions, and addresses
  • SQLite storage — no external database required
  • Automatic reconnect and reorg detection

Requirements

  • Python 3.10 or higher
  • An EVM-compatible node with an RPC endpoint (e.g. Anvil, Hardhat, Geth, Reth, Infura, Alchemy)

Installation

pip install localscan

From Source

git clone https://github.com/rakibhossain72/localscan.git
cd localscan
pip install -e .

Usage

localscan --rpc-url <RPC_URL>

LocalScan auto-detects the protocol from the URL:

  • ws:// or wss:// → WebSocket mode using eth_subscribe (real-time, recommended)
  • http:// or https:// → HTTP polling mode (polls for new blocks every 2 seconds)

Examples

# Local Anvil / Hardhat node — WebSocket
localscan --rpc-url ws://localhost:8545

# Local node — HTTP polling
localscan --rpc-url http://localhost:8545

# Remote node — WebSocket
localscan --rpc-url wss://mainnet.infura.io/ws/v3/YOUR_KEY

# Remote node — HTTPS polling
localscan --rpc-url https://mainnet.infura.io/v3/YOUR_KEY

# Custom port, persistent database
localscan --rpc-url ws://localhost:8545 --port 3000 --keep-db

All Options

  --rpc-url    RPC endpoint — ws/wss for WebSocket, http/https for polling
               (default: ws://127.0.0.1:8545)
  --host       Bind host (default: 127.0.0.1)
  --port       Bind port (default: 8000)
  --db         Path to SQLite database file (default: chain_indexer.db)
  --keep-db    Keep existing database on startup instead of wiping it
  --reload     Enable auto-reload for development

REST API

Method Endpoint Description
GET /blocks/{block_number} Get block by number
GET /transactions/{tx_hash} Get transaction by hash
GET /addresses/{address} Get address, contract, and token info

All endpoints return JSON. The web UI is served at /.

Project Structure

localscan/
  app/
    indexer/    # Block ingestion, WebSocket and HTTP polling modes
    db/         # SQLAlchemy models and session
    routes/     # FastAPI route handlers
    templates/  # Jinja2 HTML templates
    static/     # CSS assets
    cli.py      # Entry point
    main.py     # FastAPI application
  alembic/      # Database migrations

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

localscan-0.1.4.tar.gz (37.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

localscan-0.1.4-py3-none-any.whl (50.6 kB view details)

Uploaded Python 3

File details

Details for the file localscan-0.1.4.tar.gz.

File metadata

  • Download URL: localscan-0.1.4.tar.gz
  • Upload date:
  • Size: 37.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for localscan-0.1.4.tar.gz
Algorithm Hash digest
SHA256 3e184860a82a88e772818f6fc3f9eeb48724f6dd58212d9d8e7f059fbb509648
MD5 ab6cf555bb94aa605a034beafaae8259
BLAKE2b-256 2ac688c17b279e42d5bee46389a41a14cf787ca7944fed9d10788b2f1d9fdf26

See more details on using hashes here.

File details

Details for the file localscan-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: localscan-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 50.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for localscan-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e3108dd8cbc08f23c4a8978c05708c108ca72b731f08512781f01e325d7ce079
MD5 a4e988c1b4e181b9eaa223383b90d4c0
BLAKE2b-256 b9e93f547018e71f19f28e73741a30c28a89b9d1c6b61d3020bf25b877be3fc1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page