Gasless Transactions
ADVANCED FEATUREFee Sponsorship — Users send transactions without needing XLM for fees. A platform-controlled fee-bot pays on their behalf using Stellar's Fee Bump envelope.
How Fee Bump Works
01
User Signs
User builds & signs an inner payment transaction using Freighter. Zero fees set on inner tx.
02
Sponsor Wraps
InvoiceIQ's fee-bot wraps the signed inner tx in a Fee Bump envelope.
03
Sponsor Pays
The fee-bot signs and pays the transaction fee (as low as 0.00001 XLM).
04
Confirmed
Horizon processes the Fee Bump. User's payment settles with 0 XLM fee cost.
Implementation — lib/gasless.ts
// Gasless Transaction via Fee Bump (Fee Sponsorship)
// The SPONSOR pays the XLM transaction fee on behalf of the user.
import * as StellarSdk from '@stellar/stellar-sdk';
export async function buildFeeBumpTransaction(
innerTxXDR: string,
sponsorSecretKey: string, // Platform's fee bot key
feePerOp: number = 300 // stroops (~0.00003 XLM)
): Promise<string> {
const server = new StellarSdk.Horizon.Server(
'https://horizon-testnet.stellar.org'
);
// 1. Deserialize the user's signed inner transaction
const innerTx = StellarSdk.TransactionBuilder
.fromXDR(innerTxXDR, StellarSdk.Networks.TESTNET);
// 2. Wrap it in a Fee Bump transaction
const sponsorKeypair = StellarSdk.Keypair
.fromSecret(sponsorSecretKey);
const feeBumpTx = StellarSdk.TransactionBuilder
.buildFeeBumpTransaction(
sponsorKeypair, // fee source account
feePerOp, // max fee per op in stroops
innerTx, // wrapped inner tx
StellarSdk.Networks.TESTNET
);
// 3. Sponsor signs the Fee Bump envelope
feeBumpTx.sign(sponsorKeypair);
// 4. Submit the Fee Bump to Horizon
const result = await server.submitTransaction(feeBumpTx);
return result.hash; // Returns the outer fee bump TX hash
}Live Demo Sandbox
Simulate a gasless invoice payment. The transaction will be built but only simulated (no real XLM sent).
Built on CAP-0015 (Fee Bump Transactions) — official Stellar Core Advancement Proposal
Read Spec