What Are Indexers?
Indexers are specialized services that:- Extract data from blockchain nodes as blocks are produced
- Transform raw blockchain data into structured, queryable formats
- Store processed data in optimized databases (typically PostgreSQL)
- Provide APIs (usually GraphQL or REST) for applications to query data
Why Do You Need Indexers?
Blockchain Query Limitations
Slow Queries
Direct blockchain queries are slow and resource-intensive
Limited Functionality
Blockchains don’t support complex queries, joins, or aggregations
Historical Data
Accessing historical data requires scanning many blocks
Real-time Updates
Getting live updates requires constant polling
Indexer Benefits
Fast Queries
Millisecond response times for complex queries
Rich Functionality
SQL queries, joins, aggregations, and filtering
Real-time Subscriptions
WebSocket subscriptions for live data updates
Application Performance
Dramatically improve user experience
Common Use Cases
1. DeFi Applications
2. Portfolio Tracking
3. Analytics Dashboards
Neutron-Specific Data
Neutron’s unique modules generate special data that indexers can capture:Oracle Price Data
Interchain Query Results
Cron Job Executions
Architecture Patterns
1. Single Indexer
Best for: Small to medium applications with specific data needs2. Multi-Chain Indexing
Best for: Applications requiring data from multiple blockchains3. Microservice Architecture
Best for: Large applications with complex, domain-specific requirementsData Models
Core Entities
Most Neutron indexers track these fundamental entities:Neutron-Specific Entities
Performance Considerations
1. Database Optimization
2. Caching Strategy
3. Real-time Updates
Popular Indexing Solutions
SubQuery
- Best for: Cosmos ecosystem applications
- Features: GraphQL API, multi-chain support, hosted service
- Tutorial: SubQuery for Neutron
The Graph
- Best for: Ethereum-compatible chains
- Features: Decentralized network, bounty system, mature ecosystem
- Limitation: Limited Cosmos support
Custom Solutions
- Best for: Specific requirements, full control
- Technologies: Node.js, Go, Rust + PostgreSQL + GraphQL
- Effort: High development time but maximum flexibility
Getting Started
-
Identify Your Data Needs
- What entities do you need to track?
- What queries will your application make?
- How real-time do updates need to be?
-
Choose Your Technology
- SubQuery for rapid development
- Custom solution for specific needs
- Consider multi-chain requirements
-
Design Your Schema
- Map blockchain events to database entities
- Plan for query performance
- Consider data relationships
-
Implement and Deploy
- Start with basic entities
- Add complex relationships
- Optimize performance iteratively
Next Steps
SubQuery Tutorial
Learn to build a Neutron indexer with SubQuery
Custom Indexer Guide
Build a custom indexer from scratch
Best Practices
- Start Simple: Begin with basic data and add complexity gradually
- Plan for Scale: Design your schema and queries for growth
- Monitor Performance: Track query performance and database metrics
- Handle Reorgs: Plan for blockchain reorganizations and rollbacks
- Backup Data: Implement robust backup and recovery procedures