Skip to content

Fix Farcaster identity: use Steemhunt API (free) with Neynar fallback #250

@realproject7

Description

@realproject7

Problem

Farcaster identity display (P7-4, issue #39) is effectively broken — it depends on NEYNAR_API_KEY which is not configured. All wallet addresses show as truncated hex (0x0175...4dBf) instead of Farcaster usernames + avatars.

The current implementation in lib/farcaster.ts uses Neynar API only and silently returns null when the API key is missing (line 39).

Solution

Port the Steemhunt-first, Neynar-fallback pattern from the dropcast repo. Steemhunt's Farcaster Indexer API (https://fc.hunt.town) is free and requires no API key.

Reference implementation (dropcast)

  • dropcast/lib/farcaster-indexer.ts — Steemhunt client with:
    • getUserByWallet(address) — primary lookup
    • getUserByFid(fid) — FID-based lookup
    • 1-hour cache TTL, in-flight deduplication, circuit breaker, retry with backoff
    • Negative caching for known failures (422 → 4h, other 4xx → 1h)
  • dropcast/lib/neynar.ts — Neynar fallback with getUserByAddress(address)

Steemhunt API

Required changes

1. Replace lib/farcaster.ts with two-tier lookup

Rewrite lookupByAddress() to:

  1. Try Steemhunt https://fc.hunt.town/users/byWallet/{address} first
  2. If Steemhunt fails/returns null → fall back to Neynar (if NEYNAR_API_KEY is set)
  3. Return FarcasterProfile or null

Simplify from dropcast — PlotLink doesn't need the full circuit breaker/retry/negative-cache complexity. A simple implementation is fine:

  • In-memory cache (1h TTL) using a Map (no node-cache dependency needed)
  • 3s timeout per request
  • Steemhunt first → Neynar fallback

2. Update FarcasterProfile type

Current type is fine. Map Steemhunt response fields:

  • fidfid
  • usernameusername
  • displayNamedisplayName
  • pfpUrlpfpUrl

3. No changes needed to components

WriterIdentity.tsx and WriterIdentityClient.tsx already consume FarcasterProfile via lookupByAddress() — they'll work once the lookup actually returns data.

Files

  • lib/farcaster.ts — rewrite lookup logic (Steemhunt primary, Neynar fallback)
  • Reference: dropcast/lib/farcaster-indexer.ts (Steemhunt client pattern)

Acceptance criteria

  • Farcaster username + avatar displays for wallets linked to Farcaster accounts
  • Works without NEYNAR_API_KEY (Steemhunt is free)
  • Falls back to Neynar if Steemhunt returns null and API key is configured
  • Falls back to truncated address if both fail
  • npm run typecheck passes

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions