Skip to content

Add token metadata caching #37

@Miracle656

Description

@Miracle656

Background

Every time Wraith processes a transfer event, it may need to resolve the token's symbol and decimals from the SAC contract via Soroban RPC. On high-volume ledgers, this adds significant latency and RPC load. Caching token metadata after the first lookup would reduce RPC calls dramatically.

What to build

Add an in-memory (or Postgres-backed) cache for token metadata: symbol, decimals, and name. Populate on first encounter; serve from cache on subsequent events.

Key files

  • src/indexer.ts — where token metadata is currently looked up
  • src/tokenCache.ts — create this module
  • prisma/schema.prisma — optionally add a TokenMetadata model for persistence

Suggested execution

git checkout -b feat/token-metadata-caching
  1. Create src/tokenCache.ts with a Map<contractId, { symbol, decimals, name }>
  2. On service startup, populate the cache from any TokenMetadata rows in Postgres
  3. In the indexer, check cache before making an RPC call; write to cache + DB after first fetch
  4. Add a GET /tokens endpoint listing all cached tokens

Example commit message:
feat(indexer): add token metadata caching to reduce Soroban RPC calls

Acceptance criteria

  • Second encounter of the same token does not make an RPC call
  • Cache survives service restart (persisted to DB)
  • GET /tokens returns all cached token metadata

Drips Wave · Complexity: Medium · 150 points
Comment below to request assignment. PR must include Closes #[this issue].

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions