Skip to content

Add Soroban event indexer for SmartDrop contract events #14

Description

@prodbycorne

Overview

The SmartDrop Soroban contract emits events for every airdrop operation (creation, claim, expiry). This service needs to index those events so the API can answer queries like "what is the claim status for address X" without making live RPC calls on every request.

Events to Index

Based on the Soroban contract (see smartdrop-contracts):

Contract Event Data
airdrop_created airdrop_id, creator, token, total_amount, expiry_ledger
recipient_added airdrop_id, recipient, amount
token_claimed airdrop_id, recipient, amount, ledger
airdrop_expired airdrop_id, unclaimed_amount

Architecture

Soroban RPC (getEvents) → EventPoller → EventParser → PostgreSQL → REST API
  • Poll soroban_rpc.getEvents for the contract address every 5 seconds
  • Persist the last indexed ledger in DB to survive restarts
  • Store raw XDR + decoded event in contract_events table
  • Expose indexed data via new API endpoints

New Endpoints

GET /api/v1/airdrops/:id/status
GET /api/v1/airdrops/:id/recipients
GET /api/v1/recipients/:address/claims
GET /api/v1/indexer/status   (lag, last_ledger, events_count)

Acceptance Criteria

  • src/indexer/eventPoller.js polls Soroban RPC
  • Last indexed ledger persisted and resumed on restart
  • All 4 event types decoded and stored
  • API endpoints return indexed data
  • Indexer lag exposed in /api/v1/indexer/status
  • Unit test: event parser decodes XDR correctly
  • Handles RPC errors and continues polling

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official CampaignfeatureNew feature or enhancementindexingBlockchain indexing and event streaming

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions