Prerequisites
- A deployed contract on Stable testnet or mainnet. If you need one, see Deploy and Verify.
- Node.js 20 or later.
- The contract address and the ABI of the events you want to index.
1. Install and configure
2. Subscribe to live events
Use a WebSocket provider so you receive events as soon as validators finalize each block. WebSocket avoids polling overhead and keeps notification latency close to block time (~0.7 seconds on Stable).3. Backfill historical events
When a service starts, you usually need to catch up on events emitted while it was offline. UsequeryFilter with a block range.
4. Filter events by indexed arguments
Events withindexed parameters (like caller above) can be filtered server-side. Pass the filter value instead of reading every event and filtering in your app.
Handle connection drops
WebSocket connections can drop. For production indexers, implement reconnection logic so you don’t miss events.Next recommended
Track unbonding completions
Index system transaction events (unbonding completions) emitted by the protocol.
Build a P2P payment app
Apply indexing to USDT0 Transfer events and build a payment history view.
JSON-RPC reference
See which
eth_getLogs and related methods Stable supports.
