indexer-template
v1.0.0
Published
Blockchain event indexer powered by @lynx-core/indexer
Maintainers
Readme
My Indexer
Blockchain event indexer powered by @lynx-core/indexer
🚀 Quick Start
Prerequisites
- Node.js 18+ or Docker
- MongoDB (or use Docker Compose)
- RPC endpoint (Alchemy, Infura, QuickNode)
Option 1: Docker (Recommended)
# 1. Clone/setup repository
git clone <your-repo>
cd my-indexer
# 2. Configure environment
cp .env.example .env
# Edit .env and set your RPC_URL
# 3. Customize config
# Edit config/config.yaml:
# - contractAddress: your contract address
# - startBlock: deployment block number
# - events: list of events to index
# 4. Add your contract ABI
# Replace abi/YourContract.json with your actual ABI
# 5. Start services
docker-compose -f docker/docker-compose.yml up -d
# 6. Check logs
docker-compose -f docker/docker-compose.yml logs -f indexer
# 7. Verify health
curl http://localhost:3000/healthOption 2: Local Development
# 1. Install dependencies
pnpm install
# 2. Setup environment
cp .env.example .env
# Edit .env with your settings
# 3. Customize config & ABI (same as Docker)
# 4. Start MongoDB & RabbitMQ
# (Use Docker Compose or local installation)
# 5. Run in development mode
pnpm dev
# Or build and run
pnpm build
pnpm start📝 Customization
See CUSTOMIZATION_GUIDE.md for detailed instructions.
Essential Changes
config/config.yaml
contractAddress: Your contract addressstartBlock: Contract deployment blockevents: Events to indexserviceName: Unique service name
abi/YourContract.json
- Replace with your contract ABI
.env
RPC_URL: Your WebSocket RPC endpoint
That's it! No code changes needed.
🔌 API Endpoints
Health Check
GET http://localhost:3000/healthQuery Events
GET http://localhost:3000/events?fromBlock=18000000&limit=100Priority Transaction (Fast-track)
POST http://localhost:3000/transactions/priority
Content-Type: application/json
{
"txHash": "0xabc...",
"context": { "priority": "high" }
}Metrics
GET http://localhost:3000/metrics📊 Monitoring
View Logs
# Docker
docker-compose -f docker/docker-compose.yml logs -f indexer
# Local
pnpm devAccess Services
- Indexer API: http://localhost:3000
- MongoDB: mongodb://localhost:27017
- RabbitMQ Management: http://localhost:15672 (admin/admin)
Health Check
curl http://localhost:3000/health | jq🛠️ Configuration
All configuration is in config/config.yaml. No code changes needed!
Key sections:
- Service Info: serviceName, contractName, contractAddress
- Network: chainId, network, startBlock
- RPC: rpcUrl, fallbackRpcUrls
- Events: List of events to index
- Database: MongoDB settings
- Publisher: RabbitMQ/Webhook/None
- Features: priorityLane, crawler
- Performance: polling interval, batch size
See comments in config.yaml for detailed explanations.
🐛 Troubleshooting
Indexer not starting
- Check RPC_URL is valid WebSocket endpoint
- Verify MongoDB is running:
docker ps - Check logs:
docker-compose logs indexer
No events being indexed
- Verify contract address is correct
- Check startBlock is before contract deployment
- Verify events exist in contract ABI
- Check RPC endpoint has archive access (if startBlock is old)
High sync lag
- Increase polling.batchSize in config
- Use faster RPC endpoint
- Check network connectivity
- Reduce crawlerInterval
📚 Documentation
- Core Package: @lynx-core/indexer docs
- Customization: CUSTOMIZATION_GUIDE.md
- API Reference: See core package README
🤝 Support
- Open an issue: GitHub Issues
- Core package issues: Lynx Indexer Issues
📄 License
MIT
