Skip to content

Implement Soroban event indexer to sync on-chain events to database #222

Description

@ogazboiz

Join our community: https://t.me/+DOylgFv1jyJlNzM0

Description

The soroban-event-worker.ts file exists but the actual indexing logic is not implemented. The database schema (StreamEvent, IndexerState) is ready, but no on-chain events (CREATED, TOPPED_UP, WITHDRAWN, CANCELLED, COMPLETED) are being written to it. The entire API relies on indexed data — this is the most critical missing piece.

What Needs to Happen

  • Connect to Stellar RPC and poll for contract events every 5 seconds (configurable via POLL_INTERVAL_MS)
  • Cursor-based pagination using IndexerState.lastProcessedLedger
  • Parse and map each event type to a StreamEvent DB record
  • Deduplicate events by transactionHash + eventType + ledger to handle restarts safely
  • Update Stream state in DB on each relevant event (amounts, status)
  • Emit SSE broadcast after each successful event batch

Files

  • backend/src/workers/soroban-event-worker.ts
  • backend/src/services/indexerService.ts (create)

Acceptance Criteria

  • Events appear in DB within 10 seconds of on-chain confirmation
  • Indexer survives restarts without missing or duplicating events
  • All 5 event types mapped correctly

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programbackendBackend related tasks

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions