Skip to content

Freighter Wallet Integration (Stellar Only) #34

@kelly-musk

Description

@kelly-musk

Label: wallet | stellar | integration
Priority: High
Estimated Time: 6-8 hours
Value: $150 USDC


📋 Overview

Implement Freighter wallet as the single wallet solution for AFRAMP. Stellar network only, no EVM chains, no multi-wallet complexity.

Live Site: https://aframp.vercel.app/


💡 Why Freighter Only?

  • ✅ Most popular Stellar wallet (90%+ users)
  • ✅ Simple UX - one clear choice
  • ✅ Mobile app available
  • ✅ Perfect for cNGN/African stablecoins
  • ✅ Faster to build and maintain

🎯 What to Build

1. Connect Button (Header)

Not connected: [Connect Freighter]
Connected: GAXYZ...ABC123 [▼]
  ├─ Copy Address
  ├─ View on Explorer  
  └─ Disconnect

2. Connection Modal

If Freighter not installed:

  • Show install guide
  • Link to Chrome Web Store
  • Link to mobile app
  • Step-by-step instructions

If requesting connection:

  • "Waiting for Freighter approval..."
  • What AFRAMP can/cannot do
  • Security messaging

If wrong network:

  • Detect testnet vs mainnet
  • Guide to switch networks
  • Refresh button

3. Auto-Reconnect

  • Save connection to localStorage
  • Auto-reconnect on page load
  • Silent if previously connected
  • Clear if Freighter disconnected

4. Balance Fetching

  • Fetch XLM + all assets (cNGN, USDC, etc.)
  • Update every 30 seconds
  • Show in wallet dropdown
  • Handle unfunded accounts

5. Transaction Signing

  • Open Freighter popup
  • Sign transactions
  • Handle approval/rejection
  • Return transaction hash

📦 Core Files

src/
  lib/wallet/
    freighter.ts           # SDK wrapper
    walletStore.ts         # State management
    
  components/Wallet/
    ConnectButton.tsx      # Main button
    WalletModal.tsx        # Modals
    WalletDropdown.tsx     # Connected dropdown
    
  hooks/
    useWallet.ts           # Main hook

✅ Acceptance Criteria

Connection:

  • Detects if Freighter installed
  • Shows install modal if not
  • Connects on button click
  • Saves to localStorage
  • Auto-reconnects on refresh

Network:

  • Detects mainnet/testnet
  • Shows warning if wrong network
  • Provides switch instructions

Balances:

  • Fetches all asset balances
  • Updates every 30 seconds
  • Handles unfunded accounts

Transactions:

  • Signs transactions via Freighter
  • Handles user approval
  • Handles user rejection
  • Returns transaction hash

UI/UX:

  • Mobile responsive
  • Works on Freighter mobile app
  • All errors handled gracefully
  • Loading states everywhere
  • Clean, professional design

Code:

  • TypeScript (no any)
  • No console errors
  • Works in Chrome, Firefox, Edge
  • Documented

🚀 Implementation Steps

Phase 1 (3-4 hours):

  1. Install @stellar/freighter-api
  2. Create wallet store (Zustand)
  3. Build connect button
  4. Implement connection logic
  5. Add localStorage persistence

Phase 2 (2-3 hours):
6. Build connection modals
7. Add balance fetching
8. Create wallet dropdown
9. Implement disconnect

Phase 3 (1-2 hours):
10. Error handling
11. Testing (desktop + mobile)
12. Documentation


📚 Resources


🎯 Success

Complete when:

  1. ✅ One-click connection works
  2. ✅ Auto-reconnect works
  3. ✅ Balances display correctly
  4. ✅ Transaction signing works
  5. ✅ Mobile works (Freighter app)
  6. ✅ All errors handled

Quality: Rock-solid. This is the foundation for everything.


Ready? Comment "Taking this" with your completion date! 🚀

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions