Lux Docs
Lux Skills Reference

Lux Indexer

Multi-Chain Blockchain Data Indexing

Overview

Lux Indexer is a Go-based blockchain data indexing system that covers all Lux native chains (DAG and linear), EVM chains across the Lux subnet ecosystem, and a universal multi-chain indexer supporting 100+ blockchains across EVM, Solana, Bitcoin, Cosmos, Move, and other runtimes. It works alongside Blockscout (which handles C-Chain EVM indexing) to provide complete data access for the Lux multi-chain architecture.

Repository: github.com/luxfi/indexer License: MIT

Technology Stack

ComponentVersionNotes
Go1.26.1Module: github.com/luxfi/indexer
PostgreSQL14+Partitioned tables by chain_id
SQLitev2.0.3Via mattn/go-sqlite3 (embedded/local mode)
Ginkgov2.28.1BDD test framework
Gomegav1.39.1Test matchers
github.com/luxfi/databasev1.17.43Lux database abstraction
github.com/luxfi/cryptov1.17.39Lux cryptographic primitives
github.com/luxfi/idsv1.2.9Lux ID types
gorilla/muxv1.8.1HTTP routing
gorilla/websocketv1.5.4WebSocket for live DAG streaming
DockerAlpine 3.19Runtime image (golang:1.26-alpine builder)

Architecture

Three Binaries

The indexer ships three CLI binaries:

BinarySourcePurpose
indexercmd/indexer/Single-chain indexer (native DAG, linear, or EVM)
evmchainscmd/evmchains/Multi-EVM indexer (all 5 Lux subnets in one process)
multichaincmd/multichain/Universal indexer (100+ chains, all runtimes)

Chain Types

DAG-based Chains (Vertex/Parent model)

Uses github.com/luxfi/indexer/dag -- multiple parents per vertex for fast consensus convergence.

ChainPortDatabaseRPC MethodDescription
X-Chain4200explorer_xchainxvmAsset exchange, UTXOs
A-Chain4500explorer_achainavmAI compute, attestations
B-Chain4600explorer_bchainbvmCross-chain bridge
Q-Chain4300explorer_qchainqvmQuantum finality proofs
T-Chain4700explorer_tchaintvmMPC threshold signatures
Z-Chain4400explorer_zchainzvmZK transactions, privacy
K-Chain4900explorer_kchainkvmPost-quantum key management

Linear Chains (Block/Parent model)

Uses github.com/luxfi/indexer/chain -- single parent per block for strict ordering.

ChainPortDatabaseRPC MethodDescription
P-Chain4100explorer_pchainpvmPlatform, validators, staking

EVM Chains

Uses github.com/luxfi/indexer/evm -- full EVM block/transaction indexing with Blockscout-compatible API.

ChainPortDatabaseDescription
C-Chain (Go)4000explorer_cchainSmart contracts (lightweight Go alternative to Blockscout)

EVM Multi-Chain Process (evmchains)

A single-process server that indexes all 5 Lux mainnet EVM subnet chains concurrently, sharing one PostgreSQL database with table prefixes. Configured via configs/evmchains.yaml.

SlugNameChain IDPort
cchainLux C-Chain963694000
zooZoo2002005000
hanzoHanzo369635100
spcSPC369115200
parsPars4949495300

Management API on port 9000 (/health, /chains).

Universal Multi-Chain Indexer (multichain)

The multichain package and cmd/multichain binary provide a universal indexer covering 100+ chains. Configured via config/chains.yaml (1450-line YAML). Supported runtime types:

Runtime TypeExamples
evmEthereum, Arbitrum, Base, Optimism, BSC, Polygon, zkSync, Linea, Scroll, 30+ more
solanaSolana mainnet/devnet
bitcoinBitcoin mainnet/testnet (ordinals, runes, BRC-20, stamps, atomicals, RGB)
cosmosCosmos Hub, Osmosis, Injective, dYdX, Celestia, Sei, Neutron, 10+ more
moveAptos, Sui
starknetStarkNet
nearNEAR
tronTRON
tonTON
substratePolkadot, Kusama
flowFlow
tezosTezos
algorandAlgorand
cardanoCardano
icpInternet Computer
stacksStacks
hederaHedera
multiversxMultiversX
filecoinFilecoin
hyperliquidHyperliquid
lux_aiLux A-Chain
lux_bridgeLux B-Chain
lux_thresholdLux T-Chain
lux_zkLux Z-Chain
lux_graphLux G-Chain
lux_identityLux I-Chain
lux_keyLux K-Chain
lux_dexLux D-Chain

DeFi protocol indexing per chain (Uniswap, Aave, Compound, GMX, Curve, PancakeSwap, Jupiter, Raydium, etc.).

HTTP endpoints: /stats, /health, /chains, /chain/\{id\}, /metrics (Prometheus).

Core Concepts

Storage Layer

The storage/ package provides a unified storage interface:

  • storage.Store interface -- abstract storage backend
  • storage.NewUnified() -- creates KV-backed storage from storage/kv/
  • storage/query/ -- query builders for indexed data
  • Default data dir: ~/.lux/indexer/<chain>/

Database Schema (PostgreSQL)

4 migration files in migrations/. Tables are partitioned by chain_id for multi-chain isolation:

Core tables (each partitioned for chain IDs 96369, 96368, 200200, 200201, 36963):

  • chains -- chain registry (chain_id, name, symbol, rpc_url)
  • blocks -- block headers with Lux-specific fields (ext_data_hash, ext_data_gas_used, block_gas_cost)
  • transactions -- full tx data (EIP-1559, EIP-4844 blob fields)
  • internal_transactions -- traces (call, create, selfdestruct, reward)
  • logs -- event logs with 4 indexed topics
  • addresses -- address balances and stats
  • tokens -- ERC-20/721/1155 token metadata
  • token_transfers -- transfer events (batch support for ERC-1155)
  • address_token_balances / address_current_token_balances -- historical and current balances
  • address_coin_balances -- native coin balance history
  • smart_contracts -- verified contract sources with ABI
  • block_rewards -- validator/uncle/emission rewards
  • indexer_status -- per-chain indexer progress tracking
  • transaction_actions / logs_actions -- 4-byte selector and topic0 signature database

PostgreSQL extensions: pg_trgm (fuzzy search), btree_gist, pg_stat_statements.

DAG Schema (Native Chains)

For non-EVM DAG chains, separate table structures:

{chain}_vertices (id, type, parent_ids JSONB, timestamp, status, data JSONB)
{chain}_edges (source, target, type)

For linear native chains:

{chain}_blocks (id, parent_id, height, timestamp, status, data JSONB)

API Compatibility

All indexers expose Blockscout-compatible /api/v2/ endpoints:

DAG chains: /api/v2/stats, /api/v2/vertices, /api/v2/vertices/:id, /api/v2/edges, WS /api/v2/dag/subscribe

Linear chains: /api/v2/stats, /api/v2/blocks, /api/v2/blocks/:id, /api/v2/blocks/height/:height, WS /api/v2/blocks/subscribe

EVM chains: Full Blockscout API v2 compatibility (blocks, transactions, addresses, tokens, stats, search).

EVM Module (evm/)

Rich EVM indexing with subpackages:

PackagePurpose
evm/api/Blockscout-compatible REST API server
evm/account/Account balance tracking
evm/contracts/Contract verification and ABI decoding
evm/defi/DeFi protocol indexing
evm/search/Full-text search
evm/stats/Chain statistics
evm/charts/Chart data generation
evm/blob.goEIP-4844 blob transaction support
evm/erc4337.goAccount abstraction (ERC-4337) UserOp indexing
evm/mev.goMEV transaction detection
evm/uncle.goUncle/ommer block handling
evm/pending.goPending transaction tracking
evm/multichain.goMulti-chain EVM coordination
evm/enhanced.goEnhanced transaction decoding

DEX Module (dex/)

DEX adapter for Uniswap-style protocol indexing on Lux subnets.

Testing

  • Unit tests: go test -v ./... (Ginkgo/Gomega BDD style)
  • E2E tests: e2e/ directory with tests for C-Chain, X-Chain, P-Chain, client, node, funding
  • Integration tests: go test -v -tags=integration ./test/...
  • Coverage: go test -coverprofile=coverage.out ./...

Uniswap Subgraphs (The Graph Protocol)

Three subgraph repos for DEX data on Lux C-Chain, deployed to The Graph:

RepoPackageGraph CLIGraph TSNetwork
github.com/luxfi/uni-v2-subgraph@luxfi/uniswap-v2-subgraph v1.0.0^0.64.1^0.32.0lux
github.com/luxfi/uni-v3-subgraph@luxfi/uniswap-v3-subgraph v1.0.0^0.64.1^0.32.0lux
github.com/luxfi/uni-v4-subgraphlux-v4-subgraph v1.0.0^0.64.1^0.32.0lux

V2 contracts: Factory at 0xeac0a50112b5ee20cc18e42ba4d37777012afd0d (startBlock 0) V3 contracts: Factory at 0x80bBc7C4C7a59C899D1B37BC14539A22D5830a84 (startBlock 1) V4 contracts: PoolManager at 0x0000000000000000000000000000000000009010, PositionManager at 0x0000000000000000000000000000000000009011 (startBlock 1)

Subgraph infrastructure:

  • Graph Node: graph.lux.network / graph-admin.lux.network
  • IPFS: ipfs.lux.network
  • K8s services: graph-node.lux-mainnet.svc, graph-ipfs.lux-mainnet.svc
  • Deploy targets: lux, lux-testnet, lux-devnet, zoo, zoo-testnet

V3 networks.json includes Lux alongside Ethereum, Arbitrum, Base, BSC, Polygon, and 10+ other networks.

Blockchain Data Exports (github.com/luxfi/exports)

Pre-exported JSONL blockchain data for bootstrapping:

DatasetBlocksSizeFormat
LUX Mainnet (96369)0 -- 1,082,7804.2 GB44 JSONL chunks
Zoo Mainnet (200200)0 -- 7993.5 MBSingle JSONL file

Each line contains: block number, hash, parentHash, stateRoot, timestamp, gasLimit, gasUsed, baseFee, headerRLP, bodyRLP, receiptsRLP, and stateChanges (genesis only).

Genesis treasury: 0x9011E888251AB053B7bD1cdB598Db4f9DEd94714 with 2,000,000,000,000 LUX.

Alternative import: direct BadgerDB copy from ~/.luxd-mainnet/chainData/ (34M keys, 7.1 GB state).

Development

Build

# Build single-chain indexer
make build              # -> bin/indexer

# Build Docker image
make docker             # -> luxfi/indexer:latest

# Run locally
make dev-xchain         # X-Chain DAG indexer on port 4200
make dev-pchain         # P-Chain linear indexer on port 4100
make dev-zchain         # Z-Chain DAG indexer on port 4400

Run

# Single native chain
./bin/indexer -chain xchain -rpc http://localhost:9630/ext/bc/X -port 4200

# All Lux EVM subnets (single process)
./bin/evmchains -config configs/evmchains.yaml

# Universal multi-chain
./bin/multichain -config config/chains.yaml -port 5000 -max-chains 100

# List available chains
./bin/indexer -list

Docker

# Dockerfile builds both binaries (cross-compile, CGO_ENABLED=0)
docker build --build-arg VERSION=$(git describe --tags) -t luxfi/indexer .

# Ports exposed: 4000-4900, 5000-5300, 9000
# Entrypoint: indexer

Environment Variables

VariablePurposeDefault
RPC_ENDPOINTChain RPC URLchain-specific
DATABASE_URLPostgreSQL connection--
HTTP_PORTAPI server portchain-specific
POLL_INTERVALStats poll interval30s
DATA_DIRLocal storage directory~/.lux/indexer/<chain>
LOG_LEVELLogging verbosityinfo

Subgraph Development

# V2/V3/V4 subgraphs
cd ~/work/lux/uni-v{2,3,4}-subgraph
pnpm install            # or npm install
npm run codegen         # Generate AssemblyScript types
npm run build           # Compile subgraph
npm run deploy-lux      # Deploy to Lux Graph Node

File Structure

indexer/
  cmd/
    indexer/             # Single-chain CLI (DAG/linear/EVM)
    evmchains/           # Multi-EVM subnet CLI
    multichain/          # Universal 100+ chain CLI
  dag/                   # DAG vertex/edge indexer library
  chain/                 # Linear block indexer library
  evm/                   # EVM indexer (api/, account/, contracts/, defi/, search/, stats/)
  dex/                   # DEX protocol adapter
  multichain/            # Universal multi-chain manager
  storage/               # Unified storage (kv/, query/)
  achain/ bchain/ kchain/ pchain/ qchain/ tchain/ xchain/ zchain/  # Per-chain adapters
  config/chains.yaml     # Universal chain config (1450 lines, 100+ chains)
  configs/evmchains.yaml # Lux EVM subnet config (5 chains)
  migrations/            # PostgreSQL schema (4 files)
  e2e/                   # End-to-end tests (cchain, xchain, pchain, node, client)
  Makefile               # Build, test, dev, Docker targets
  go.mod                 # github.com/luxfi/indexer, Go 1.26.1

On this page