Skip to content

Implement fee-bump transaction support for sponsored accounts with zero XLM balance #30

Description

@prodbycorne

Problem

New Stellar accounts with no XLM cannot pay transaction fees. SmartDrop targets early-stage token participants who may have only the staking asset (e.g. a project's custom token) but no native XLM for fees. Without fee-bump support, these users are blocked from depositing.

Expected Behaviour

When the app detects that the connected wallet's XLM balance is below the minimum fee reserve, it offers to wrap the user's transaction in a fee-bump envelope signed by a sponsor keypair (provided via environment variable or a backend endpoint). The sponsor pays the fee; the inner transaction is signed by the user.

Acceptance Criteria

  • src/lib/soroban.ts gains a buildFeeBumpTransaction(innerTx, sponsorPublicKey, networkPassphrase) utility using TransactionBuilder.buildFeeBump from the Stellar SDK
  • SorobanService.lockAssets and unlockAssets detect XLM balance < fee threshold (fetched via fetchAccountBalances) and switch to fee-bump mode automatically
  • The sponsor public key comes from process.env.NEXT_PUBLIC_FEE_SPONSOR_PUBLIC_KEY; the sponsor signature is obtained from a backend API route POST /api/sign-fee-bump that receives the inner XDR and returns the signed fee-bump XDR
  • The API route is an optional Next.js Route Handler (src/app/api/sign-fee-bump/route.ts) that uses the sponsor secret stored in STELLAR_FEE_SPONSOR_SECRET (server-side only, never exposed to the browser)
  • A warning banner in the deposit modal informs users when fee-bump mode is active: "Your fees are sponsored for this transaction"
  • A Vitest test constructs a mock inner transaction and verifies buildFeeBumpTransaction wraps it correctly (correct source, fee, inner tx)

Relevant Files

  • src/lib/soroban.tsbuildFeeBumpTransaction, integrate into lockAssets / unlockAssets
  • src/app/api/sign-fee-bump/route.ts — create new API route
  • src/lib/stellar.tsfetchAccountBalances (needed for XLM check)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Official CampaignCampaign: Official CampaignhardRequires deep domain knowledge — Soroban, Stellar SDK, or complex statesorobanSoroban smart-contract integration (XDR, RPC, transaction building)walletFreighter wallet integration, session, and network switching

    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