Skip to content

Backend: Build Smart Contract Event Indexer with Real-Time WebSocket Streams #447

Description

@Smartdevs17

Context

Applications need real-time visibility into on-chain events (payments, disputes, settlements) without polling RPC endpoints. AgenticPay lacks a dedicated event indexer with streaming capabilities.

Current Limitation/Problem

Frontend and SDK clients poll the backend for transaction status, creating unnecessary load. There is no unified event stream for contract state changes across Stellar and EVM.

Expected Outcome

A horizontally scalable event indexer that ingests contract events from both Stellar Soroban and EVM chains, normalizes them into a common schema, and pushes them to subscribed clients via WebSocket with automatic reconnection.

Acceptance Criteria

  • Index all relevant events (PaymentSent, PaymentReceived, DisputeRaised, SettlementCompleted, etc.) from Stellar Soroban and EVM
  • Push events to authenticated WebSocket clients within 2 seconds of on-chain confirmation
  • Support event filtering by contract address, event type, and time range
  • Handle chain reorganizations (at least 6 confirmations deep)
  • Expose REST API for historical event replay
  • Auto-prune events older than configurable retention period
  • Maintain at-least-once delivery semantics with deduplication

Technical Scope

  • backend/src/services/indexer/ - new indexer service
  • backend/src/services/indexer/soroban-listener.ts - Stellar event polling
  • backend/src/services/indexer/evm-listener.ts - EVM event polling (ethers.js)
  • backend/src/websocket/event-stream.ts - WebSocket handler with Socket.IO or ws
  • Prisma schema: IndexedEvent, WebSocketSubscription models
  • Redis pub/sub for cross-instance event broadcasting
  • BullMQ queue for event persistence and deduplication
  • Edge cases: RPC rate limits, connection drops, missed blocks, reorgs

Metadata

Metadata

Assignees

Labels

200-points200 point issueStellar WaveIssues in the Stellar wave programdrips-waveIssues in the Drips Wave programhighHigh complexity issue

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions