indexer

module
v1.4.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2026 License: MIT

README

Explorer

Single-binary block explorer for EVM and multi-chain networks. Indexes, serves API, embeds frontend. Zero external dependencies.

explorer
├── /v1/explorer/*        Explorer API v2 REST endpoints
├── /v1/explorer/graphql   GraphQL endpoint
├── /v1/explorer/ws        WebSocket / SSE realtime subscriptions
├── /*                     Embedded frontend (Next.js static export)
├── /health                Healthcheck
│
├── SQLite (WAL)           Zero-config embedded database
├── ZapDB               Fast KV layer for hot lookups
└── Replicate → S3         E2E PQ encrypted streaming backups

Quick Start

# Build
go build -o explorer ./cmd/explorer/

# Run — indexes chain, serves API + frontend on :8090
./explorer --rpc=http://localhost:9650/ext/bc/C/rpc

# That's it. Open http://localhost:8090
Docker
docker build -f Dockerfile.explorer -t explorer .
docker run -p 8090:8090 -v explorer-data:/data \
  -e RPC_ENDPOINT=http://node:9650/ext/bc/C/rpc \
  explorer
E2E Post-Quantum Encrypted Streaming Backups

Every SQLite write is continuously streamed to S3, encrypted end-to-end before leaving the process:

SQLite WAL → Replicate → age (ML-KEM-768 ∥ X25519) → S3
                          ↑
                          NIST FIPS 203 lattice KEM
                          + classical ECDH (defense-in-depth)
                          + ChaCha20-Poly1305 AEAD (64KB chunks)
                          + fresh ephemeral keys per segment
                          + forward secrecy (keys zeroed after use)
  • Quantum-resistant: ML-KEM-768 protects against harvest-now-decrypt-later
  • Hybrid: secure if either classical or post-quantum algorithm holds
  • Streaming: never buffers the full database — 64KB encrypted chunks
  • Point-in-time: restore to any transaction ID, not just the latest snapshot
  • No key rotation: each WAL segment generates fresh ephemeral keypairs
  • Zero trust S3: data is ciphertext before it leaves the process, S3 never sees plaintext
# Generate PQ keypair
age-keygen -pq -o explorer.key

# Enable streaming backups
export REPLICATE_S3_ENDPOINT=https://s3.amazonaws.com
export REPLICATE_S3_BUCKET=explorer-backups
export REPLICATE_AGE_RECIPIENT=age1pq1...  # from explorer.key

# Restore to point-in-time
explorer restore --from=s3://explorer-backups/mainnet --to=./restored.db \
  --age-identity=explorer.key --txid=12345

Architecture

┌─────────────────────────────────────────────────────────┐
│                      explorer binary                     │
│                                                           │
│  ┌──────────────┐  ┌───────────────┐  ┌──────────────┐  │
│  │  Indexer      │  │  API Server   │  │  Frontend    │  │
│  │  goroutines   │  │  (Base)       │  │  (embedded)  │  │
│  │               │  │               │  │              │  │
│  │  EVM blocks   │  │ /v1/explorer  │  │  Next.js     │  │
│  │  txs, logs    │  │  REST, GQL    │  │  static      │  │
│  │  tokens       │  │  WebSocket    │  │  export      │  │
│  │  traces       │  │  SSE          │  │  go:embed    │  │
│  │  DeFi, NFTs   │  │  JSON-RPC     │  │              │  │
│  └───────┬───────┘  └───────┬───────┘  └──────────────┘  │
│          │ write             │ read-only                   │
│          ▼                   ▼                             │
│  ┌─────────────────────────────────────┐                  │
│  │  SQLite (WAL)  +  ZapDB (KV)     │                  │
│  └──────────────────┬──────────────────┘                  │
│                     │ continuous WAL stream                │
│  ┌──────────────────▼──────────────────┐                  │
│  │  S3 (E2E PQ encrypted)              │                  │
│  │  ML-KEM-768 + X25519 + ChaCha20    │                  │
│  │  point-in-time restore to any TXID  │                  │
│  └─────────────────────────────────────┘                  │
└───────────────────────────────────────────────────────────┘
Rust Static Libraries (Optional)

Pure Go covers everything by default. The Rust verification services can optionally be compiled as a static library and linked via CGO:

explorer-rs/ffi/ → libexplorer_ffi.a
  explorer_verify_solidity()     smart-contract-verifier
  explorer_verify_vyper()        vyper verification
  explorer_lookup_signature()    sig-provider (4-byte selectors)
  explorer_lookup_event()        event signature lookup
  explorer_free()                memory management
# Pure Go (default)
go build -o explorer ./cmd/explorer/

# With Rust linked
cd explorer-rs/ffi && cargo build --release
CGO_ENABLED=1 CGO_LDFLAGS="-L... -lexplorer_ffi" go build -tags rustffi -o explorer ./cmd/explorer/

Chains

EVM (C-Chain + Subnet Chains)

Full EVM explorer feature parity:

  • Blocks (consensus, uncle, EIP-4844 blobs, Lux extended header)
  • Transactions (type 0-3, internal traces via 3 tracer types, state changes)
  • Tokens (ERC-20, ERC-721, ERC-1155, batch transfers, historical balances)
  • Smart contracts (Solidity/Vyper verification, proxy detection, ABI decode)
  • Account Abstraction (ERC-4337 UserOps, bundlers, paymasters)
  • MEV (sandwich, frontrun, backrun, liquidation detection)
  • DeFi (AMM V2/V3, perps, lending, staking, bridges, CLOB, NFT marketplaces)
  • Search, statistics, gas oracle, charts, user accounts, API keys, watchlists
DAG Chains (X, A, B, Q, T, Z, K)
Chain Purpose
X-Chain Asset exchange, UTXOs, atomic swaps
A-Chain AI compute, attestations, model registration
B-Chain Cross-chain bridge, proof validation
Q-Chain Quantum finality, lattice proofs
T-Chain Threshold MPC, key shares
Z-Chain Zero-knowledge, shielded transfers
K-Chain PQ key management, certificate lifecycle
Multi-Chain (100+ External)

Parallel indexer: Ethereum, Polygon, Arbitrum, Optimism, Base, BSC, Solana, Bitcoin (Ordinals/Runes/BRC-20), Cosmos, Aptos, Sui, NEAR, Tron, TON, and more.

API

All endpoints under /v1/explorer/.

GET  /v1/explorer/blocks
GET  /v1/explorer/blocks/{hash_or_number}
GET  /v1/explorer/transactions
GET  /v1/explorer/transactions/{hash}
GET  /v1/explorer/transactions/{hash}/token-transfers
GET  /v1/explorer/transactions/{hash}/internal-transactions
GET  /v1/explorer/transactions/{hash}/logs
GET  /v1/explorer/addresses/{hash}
GET  /v1/explorer/addresses/{hash}/transactions
GET  /v1/explorer/addresses/{hash}/tokens
GET  /v1/explorer/tokens
GET  /v1/explorer/tokens/{address}/holders
GET  /v1/explorer/smart-contracts/{address}
POST /v1/explorer/smart-contracts/{address}/verify
GET  /v1/explorer/search
GET  /v1/explorer/stats
POST /v1/explorer/graphql
WS   /v1/explorer/ws
POST /v1/explorer/rpc  (Etherscan-compatible)

White-Label

Zero branding in code. Everything at runtime:

explorer --chain-name="My Chain" --coin=MYC --chain-id=12345

Configuration

# Required
RPC_ENDPOINT=http://localhost:9650/ext/bc/C/rpc

# Optional
DATA_DIR=~/.explorer/data
HTTP_ADDR=:8090
CHAIN_ID=96369
CHAIN_NAME=My Chain
COIN_SYMBOL=ETH

# PQ Encrypted Backups
REPLICATE_S3_ENDPOINT=https://s3.amazonaws.com
REPLICATE_S3_BUCKET=explorer-backups
REPLICATE_AGE_RECIPIENT=age1pq1...

Testing

go test ./...                  # 431+ tests, 22 packages
go test ./explorer/...         # API layer (35 tests)
go test ./evm/...              # EVM indexer
go test ./storage/...          # Storage backends

License

MIT

Directories

Path Synopsis
Package achain provides the A-Chain (AI) adapter for the DAG indexer.
Package achain provides the A-Chain (AI) adapter for the DAG indexer.
Package bchain provides the B-Chain (Bridge) adapter for cross-chain bridge operations.
Package bchain provides the B-Chain (Bridge) adapter for cross-chain bridge operations.
Package chain provides shared linear chain indexing for LUX chains (P).
Package chain provides shared linear chain indexing for LUX chains (P).
cmd
indexerd command
Package main provides the standalone chain-indexer daemon.
Package main provides the standalone chain-indexer daemon.
Package daemon is the chain-indexer bootstrap: it owns the per-chain indexers and the /v1/indexer/* HTTP API.
Package daemon is the chain-indexer bootstrap: it owns the per-chain indexers and the /v1/indexer/* HTTP API.
Package dag provides shared DAG indexing for LUX chains (X, A, B, Q, T, Z).
Package dag provides shared DAG indexing for LUX chains (X, A, B, Q, T, Z).
Package dex provides the DEX L2 subnet adapter for the indexer.
Package dex provides the DEX L2 subnet adapter for the indexer.
evm
Package evm provides a unified EVM indexer for all Lux EVM chains.
Package evm provides a unified EVM indexer for all Lux EVM chains.
account
Package account provides user account management for the EVM indexer.
Package account provides user account management for the EVM indexer.
api
Package api provides REST, RPC, GraphQL, and WebSocket APIs for the EVM indexer.
Package api provides REST, RPC, GraphQL, and WebSocket APIs for the EVM indexer.
charts
Package charts provides time-series data for blockchain visualization.
Package charts provides time-series data for blockchain visualization.
contracts
Package contracts provides smart contract verification and proxy detection.
Package contracts provides smart contract verification and proxy detection.
defi
Package defi provides DeFi protocol indexing for the Lux EVM indexer.
Package defi provides DeFi protocol indexing for the Lux EVM indexer.
market
Package market provides coin/token price fetching and caching from external price oracles (CoinGecko, CoinMarketCap).
Package market provides coin/token price fetching and caching from external price oracles (CoinGecko, CoinMarketCap).
search
Package search provides unified search functionality across all indexed blockchain entities.
Package search provides unified search functionality across all indexed blockchain entities.
stats
Package stats provides Prometheus metrics export for blockchain statistics.
Package stats provides Prometheus metrics export for blockchain statistics.
transport
Package transport provides pluggable RPC transports for the EVM indexer.
Package transport provides pluggable RPC transports for the EVM indexer.
Package explorer provides a block explorer API layer.
Package explorer provides a block explorer API layer.
testutil
Package testutil provides test data factories for explorer tests.
Package testutil provides test data factories for explorer tests.
Package identity provides the I-Chain adapter for the DAG indexer.
Package identity provides the I-Chain adapter for the DAG indexer.
Package kchain provides the K-Chain (KMS) adapter for the DAG indexer.
Package kchain provides the K-Chain (KMS) adapter for the DAG indexer.
Package mpc provides the M-Chain adapter for the DAG indexer.
Package mpc provides the M-Chain adapter for the DAG indexer.
Package oracle provides the O-Chain adapter for the DAG indexer.
Package oracle provides the O-Chain adapter for the DAG indexer.
Package pchain provides the P-Chain (Platform) adapter for the LINEAR chain indexer.
Package pchain provides the P-Chain (Platform) adapter for the LINEAR chain indexer.
Package qchain provides the Q-Chain (Quantum) adapter for the DAG indexer.
Package qchain provides the Q-Chain (Quantum) adapter for the DAG indexer.
Package relay provides the R-Chain adapter for the DAG indexer.
Package relay provides the R-Chain adapter for the DAG indexer.
Package rpcadapter provides the shared JSON-RPC plumbing used by every chain-specific DAG adapter (ai, bridge, key, mpc, oracle, quantum, threshold, zk, ...).
Package rpcadapter provides the shared JSON-RPC plumbing used by every chain-specific DAG adapter (ai, bridge, key, mpc, oracle, quantum, threshold, zk, ...).
Package storage provides a pluggable storage interface for the LUX indexer.
Package storage provides a pluggable storage interface for the LUX indexer.
kv
Package kv provides a unified key-value storage layer using github.com/luxfi/database.
Package kv provides a unified key-value storage layer using github.com/luxfi/database.
query
Package query provides a query layer for indexed data.
Package query provides a query layer for indexed data.
Package tchain provides T-Chain (Teleport) adapter for DAG indexing.
Package tchain provides T-Chain (Teleport) adapter for DAG indexing.
Package xchain provides the X-Chain (UTXO) adapter for the DAG indexer.
Package xchain provides the X-Chain (UTXO) adapter for the DAG indexer.
Package zchain provides the Z-Chain (Privacy) adapter for DAG indexing.
Package zchain provides the Z-Chain (Privacy) adapter for DAG indexing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL