/On-Chain Event Indexing
📡
On-Chain Event Indexing
Day 1 · Smart Contract + Backend Integration · 30 min
| Approach | Pros | Cons |
| The Graph | Structured, queryable, ecosystem support | Delay, hosted dependency, limited custom logic |
| Custom Indexer | Full control, custom business logic | Dev overhead, maintenance burden |
| RPC Polling | Simple to implement | Expensive, unreliable at scale |
| Event Subscription | Real-time, low latency | Node-dependent, connection drops |
Handling Reorgs in Indexers:
Key Points
- ▸Hybrid approach: The Graph for reads, custom indexer for critical events
- ▸Always store block number AND block hash with events
- ▸Verify parent hash chain to detect reorgs
- ▸Use finalized flag with confirmation threshold
- ▸Idempotent event processing is non-negotiable