-
Notifications
You must be signed in to change notification settings - Fork 76
Closed
Labels
Stellar WaveIssues in the Stellar wave programIssues in the Stellar wave programfrontendstellarStellar blockchain integrationStellar blockchain integrationtippingCrypto tipping feature using StellarCrypto tipping feature using Stellar
Description
Description
Create a utility module for building Stellar payment transactions using @stellar/stellar-sdk. This will be used by the tip modal to construct XLM payment transactions from viewer to creator.
Current State
We have @stellar/stellar-sdk installed (from the Stellar migration), but no payment-specific utilities yet. We need a clean abstraction for building tip transactions.
What needs to happen
- Create
lib/stellar/payments.tswith the following functions:
import {
Server,
TransactionBuilder,
Networks,
Operation,
Asset,
BASE_FEE,
Memo,
Transaction,
} from "@stellar/stellar-sdk";
interface BuildTipTransactionParams {
sourcePublicKey: string; // Viewer's Stellar wallet
destinationPublicKey: string; // Creator's Stellar wallet
amount: string; // XLM amount (e.g., "10.0000000")
network: "testnet" | "mainnet";
}
export async function buildTipTransaction(
params: BuildTipTransactionParams
): Promise<Transaction>
export async function submitTransaction(
transaction: Transaction,
network: "testnet" | "mainnet"
): Promise<{ success: boolean; hash?: string; ledger?: number; error?: string }>-
Implementation details:
- Use
Serverfrom@stellar/stellar-sdkto connect to Horizon API - Testnet:
https://horizon-testnet.stellar.org - Mainnet:
https://horizon.stellar.org - Load source account with
server.loadAccount(sourcePublicKey) - Build transaction with
TransactionBuilder - Add
Operation.payment()withAsset.native()(XLM) - Add memo:
Memo.text("StreamFi Tip") - Set timeout: 30 seconds
- Use
BASE_FEEfor transaction fee
- Use
-
Error handling:
- Catch and return errors from
server.loadAccount()(account not found) - Catch and return errors from
server.submitTransaction()(insufficient balance, etc.) - Include Stellar result codes in error responses
- Catch and return errors from
-
Get network from environment variable:
- Read
NEXT_PUBLIC_STELLAR_NETWORK(set by user: "testnet" or "mainnet")
- Read
Files affected
- New file:
lib/stellar/payments.ts
Acceptance criteria
-
lib/stellar/payments.tsfile created with both functions -
buildTipTransaction()constructs valid Stellar payment transaction -
submitTransaction()submits to Horizon API and returns result - Network selection works (testnet vs mainnet based on param)
- Transactions include memo: "StreamFi Tip"
- TypeScript types defined for all params and returns
- Error handling implemented with clear error messages
- Tested on Stellar Testnet with real wallet addresses
Useful resources
Loom Video Requirement
Before submitting your PR, you must record a short Loom video demonstrating:
- The
lib/stellar/payments.tsfile and its code- Testing
buildTipTransaction()with console.log showing the transaction object- Testing
submitTransaction()on Testnet and showing the returned hash- Viewing the transaction on Stellar Expert Testnet explorer
Include the Loom link in your PR description.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Stellar WaveIssues in the Stellar wave programIssues in the Stellar wave programfrontendstellarStellar blockchain integrationStellar blockchain integrationtippingCrypto tipping feature using StellarCrypto tipping feature using Stellar