Skip to content

Implement on-chain event indexing for memberships #14

Description

@Lakes41

Summary

Add an indexing worker that consumes MembershipNFT events and synchronises membership state into the access API database.

Current Behaviour

The Solidity contract emits MembershipMinted, MembershipRenewed, and MembershipSuspended events, and the contracts package exposes ABI fragments. The backend currently relies on seeded database data and does not ingest contract events.

Expected Behaviour

The backend should be able to synchronise membership records from on-chain events for a configured MEMBERSHIP_NFT_ADDRESS and CHAIN_ID.

Suggested Implementation

Create an indexer package or access API worker that connects to an EVM RPC endpoint, scans from a configured block, decodes membership events, and upserts wallet, member, membership, and role-related state. Persist indexing progress to avoid duplicate processing.

Files or Areas Likely Affected

  • packages/contracts/src/index.ts
  • contracts/src/MembershipNFT.sol
  • apps/access-api/prisma/schema.prisma
  • apps/access-api/src/services/
  • apps/access-api/src/workers/
  • .env.example
  • README.md

Acceptance Criteria

  • Indexer reads configured chain ID, contract address, and RPC URL
  • MembershipMinted creates or updates wallet, member, and membership records
  • MembershipRenewed updates membership expiry
  • MembershipSuspended updates suspension state
  • Indexer persists last processed block or equivalent checkpoint
  • Tests cover event decoding and idempotent database writes

Additional Notes

Assumption: this should remain MVP-friendly and can start as a manually invoked worker before becoming a long-running service.

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official Campaign

Type

No type

Fields

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