Skip to content

mayaswap/pscan

Repository files navigation

EthereScan

A brutalist Ethereum block explorer built on Rust and Reth.

Architecture

┌─────────────────────────────────────────────────────────────────┐
│                         FRONTEND                                │
│  Next.js + Tailwind (Brutalist B&W, JetBrains Mono)            │
└──────────────────────┬──────────────────────────────────────────┘
                       │ HTTP/WebSocket
┌──────────────────────▼──────────────────────────────────────────┐
│                    RUST API SERVER (Axum)                       │
│  REST API │ WebSocket │ Price Service                          │
└──────────────────────┬──────────────────────────────────────────┘
                       │
┌──────────────────────▼──────────────────────────────────────────┐
│                    RUST INDEXER                                 │
│  Block Sync │ Token Parser │ Trace Parser                      │
└───────┬─────────────────────────────────────────┬───────────────┘
        │ Direct MDBX read                        │ Write
┌───────▼───────┐                         ┌───────▼───────┐
│   Reth Node   │                         │  ClickHouse   │
│   (MDBX DB)   │                         │  (Analytics)  │
└───────────────┘                         └───────────────┘

Tech Stack

Layer Technology
Frontend Next.js 14, Tailwind, wagmi
API Axum (Rust)
Indexer Rust + reth-db crate
Database ClickHouse
Cache Redis
Node Reth
Deploy Kubernetes

Project Structure

etherescan/
├── crates/
│   ├── etherescan-common/      # Shared types, config, db
│   ├── etherescan-api/         # Axum REST API + WebSocket
│   ├── etherescan-indexer/     # Blockchain indexer
│   └── etherescan-prices/      # CoinGecko price service
├── apps/web/                   # Next.js frontend
├── deploy/
│   ├── k8s/                    # Kubernetes manifests
│   ├── docker/                 # Dockerfiles
│   └── clickhouse/             # ClickHouse migrations
├── Cargo.toml                  # Rust workspace
└── config.toml                 # Configuration

Getting Started

Prerequisites

  • Rust 1.82+
  • Node.js 20+
  • Reth node with synced data
  • ClickHouse
  • Redis

Configuration

Copy and edit the configuration:

cp config.toml config.local.toml

Edit config.local.toml with your settings:

  • Reth database paths
  • ClickHouse connection
  • Redis connection

Running Locally

  1. Start ClickHouse and Redis:
docker compose up -d clickhouse redis
  1. Run the Indexer:
cargo run --release -p etherescan-indexer
  1. Run the API Server:
cargo run --release -p etherescan-api
  1. Run the Frontend:
cd apps/web
npm install
npm run dev

Building for Production

# Build Rust binaries
cargo build --release

# Build Docker images
docker build -f deploy/docker/Dockerfile.api -t etherescan/api .
docker build -f deploy/docker/Dockerfile.indexer -t etherescan/indexer .
docker build -f deploy/docker/Dockerfile.web -t etherescan/web apps/web

Deploying to Kubernetes

# Create namespace and resources
kubectl apply -f deploy/k8s/namespace.yaml
kubectl apply -f deploy/k8s/configmap.yaml
kubectl apply -f deploy/k8s/clickhouse.yaml
kubectl apply -f deploy/k8s/redis.yaml
kubectl apply -f deploy/k8s/api.yaml
kubectl apply -f deploy/k8s/indexer.yaml
kubectl apply -f deploy/k8s/web.yaml

API Endpoints

Blocks

  • GET /api/v1/blocks - List blocks
  • GET /api/v1/block/:number - Block by number
  • GET /api/v1/block/hash/:hash - Block by hash
  • GET /api/v1/block/:number/txs - Block transactions

Transactions

  • GET /api/v1/txs - List transactions
  • GET /api/v1/tx/:hash - Transaction by hash
  • GET /api/v1/address/:addr/txs - Address transactions

Addresses

  • GET /api/v1/address/:addr - Address info
  • GET /api/v1/address/:addr/tokens - Token transfers

Tokens

  • GET /api/v1/tokens - List tokens
  • GET /api/v1/token/:addr - Token info
  • GET /api/v1/token/:addr/transfers - Token transfers

Gas

  • GET /api/v1/gas - Current gas prices
  • GET /api/v1/gas/history - Historical gas data

Search

  • GET /api/v1/search?q= - Universal search

Stats

  • GET /api/v1/stats - Network statistics

WebSocket

Connect to /ws and subscribe to events:

{ "action": "subscribe", "channels": ["blocks", "transactions"] }

Event types:

  • block - New block
  • tx - New transaction
  • address_activity - Activity on watched address

Design System

The frontend uses a brutalist design:

  • Black and white colors only
  • JetBrains Mono font
  • 1px borders, no shadows, no rounded corners
  • Hover states: inverted colors

License

MIT

About

PulseChain Block Explorer - PScan

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors