Chain Indexer
The Chain Indexer transforms blockchain-optimized event logs and storage into domain model data structures optimized for application queries, providing millisecond-latency access to historical blockchain state.
Overview
The Chain Indexer bridges the gap between blockchain data structures and application requirements. Blockchain storage optimizes for consensus verification, not application queries. The indexer transforms event logs into domain models that serve application needs efficiently.
Application queries demand millisecond response times. Blockchain node queries for historical data can take seconds or fail entirely for complex aggregations. The Chain Indexer maintains query-optimized representations of blockchain state for responsive application experiences.
Data translation
Event processing
Event subscription
The indexer subscribes to contract events through the Chain Gateway. New block notifications trigger event retrieval for monitored contracts. Historical sync processes missed blocks during indexer downtime.
Handler execution
Event handlers receive decoded event parameters. Handlers execute business logic to update domain models. Handler execution is deterministic—the same events always produce the same state.
State computation
Some domain models require computed state from multiple events. Transfer events update balance aggregates. Compliance events affect investor verification status. The indexer maintains these computed values for efficient queries.
Domain models
The indexer constructs domain models optimized for application use cases:
| Domain model | Source events | Query patterns |
|---|---|---|
| Asset balances | Transfer, Mint, Burn | Balance by holder, asset totals |
| Investor portfolios | Transfer, Verification | Holdings by investor, portfolio value |
| Transaction history | All events | Filtered by asset, investor, time |
| Compliance status | Verification events | Current status, history |
| Distribution records | Distribution events | Pending, completed, by period |
Consistency handling
Block confirmation
Events from recent blocks may revert due to chain reorganizations. The indexer tracks confirmation depth and marks recent data as provisional. Applications display confirmation status for recent transactions.
Reorg recovery
Chain reorganizations require state rollback and reprocessing. The indexer maintains rollback capability for configurable block depths. Detected reorgs trigger:
- Identification of affected blocks
- State rollback to fork point
- Reprocessing of canonical chain
- Notification to connected clients
Idempotent processing
Event processing is idempotent. Reprocessing the same events produces identical state. This property enables safe recovery from any failure scenario.
Query performance
Indexed access
Database schemas optimize for expected query patterns. Indexes cover common filter and sort operations. Query analysis guides index maintenance.
Materialized aggregates
Frequently accessed aggregates materialize in dedicated tables. Balance totals, transaction counts, and status summaries update incrementally rather than computing on demand.
Pagination support
Large result sets paginate efficiently through cursor-based navigation. Consistent ordering guarantees stable pagination across concurrent updates.
Real-time updates
Connected clients receive real-time state updates through WebSocket connections. Event processing triggers notifications to subscribed clients. Update latency from block confirmation to client notification measures in milliseconds.
Monitoring
Indexer health exposes through multiple metrics:
| Metric | Purpose | Alert threshold |
|---|---|---|
| Block lag | Processing currency | Blocks behind > 10 |
| Processing time | Handler performance | P99 > 100ms |
| Error rate | Handler failures | Rate > 0.1% |
| Reorg depth | Chain stability | Depth > 3 blocks |

See also
- Chain Gateway for blockchain connectivity
- Database for storage architecture
- Contract Runtime for event decoding
Contract Runtime
The Contract Runtime provides a secure abstraction for smart contract interactions, managing ABI encoding, call execution, and state queries with automatic retry and error classification.
Chain Gateway
The Chain Gateway provides application-aware load balancing across blockchain nodes, supporting both public networks and private consortium deployments with intelligent routing, failover, and performance optimization.