Indexer And Frontend Patterns Reference
Reference architecture for event-driven dapps on Rivellum.
Data Plane
| Plane | Source | Contract |
|---|
| Hot updates | /events/stream | low-latency UI state transitions |
| Historical backfill | GET /v1/events/query | deterministic catch-up |
| Receipt detail | GET /v1/mist/receipts/:id | per-call verification |
Event Ingestion Pattern
const ws = new WebSocket('wss://rpc.rivellum.network/events/stream');
ws.onmessage = (msg) => enqueue(JSON.parse(msg.data));
Backfill window:
curl "https://rpc.rivellum.network/v1/events/query?from_batch=1000&limit=1000"
Indexer Storage Schema (Minimal)
| Table | Key | Notes |
|---|
| events | (batch_height, event_id) | immutable append |
| receipts | receipt_id | canonical execution record |
| checkpoints | consumer_name | last processed batch/offset |
Deterministic Reducer Rules
- Reducers are pure and idempotent.
- Event ordering uses batch height + intra-batch sequence.
- Reprocess from checkpoint must converge to same state.
- UI state derives from indexed events, not optimistic assumptions.
Recovery Pattern
- load checkpoint
- backfill via
events/query from checkpoint+1
- switch to stream
- periodic reconciliation with receipt snapshots
Frontend Query Pattern
const events = await fetch(
'https://rpc.rivellum.network/v1/events/query?topic=contract.called&from_batch=1234&limit=200'
).then(r => r.json());
Monitoring Signals
| Signal | Meaning |
|---|
| stream lag | consumer behind head |
| replay queue depth | retry pressure |
| reducer mismatch count | deterministic bug risk |
| checkpoint staleness | data-plane outage risk |
Related References
/docs/dev/debugging-replay
/docs/dev/contract-lifecycle
/docs/dev/production-operations