TL;DR β A sponsor account fronts the ~0.5 XLM reserve needed to open the userβs trustline, and the user repays it inside the same swap using the assets they are already trading. The user does not need to hold XLM beforehand, and never has to think about trustlines at all.
New to trustlines? Read the Trustlines concept page first. In short: on Stellar, an account must open a trustline β and lock up a small XLM base reserve β before it can hold any non-native asset.
The problem it solves
On Stellar, before an account can receive a token (say USDC), it must:- Understand what a trustline is.
- Own XLM to pay the base reserve (~0.5 XLM per trustline) plus the transaction fee.
- Submit a separate
changeTrusttransaction before the swap.
Benefits
How it works
Gasless Trustline runs on the Stellar Classic DEX (SDEX) using path payments, and applies only to the first swap for a given user (i.e., when that user does not yet have a trustline for the output asset).The role of the sponsor
A sponsor is a wallet you control (your appβs account) that temporarily covers the XLM base reserve required to open the userβs trustline. Two Stellar primitives make this safe and atomic:beginSponsoringFutureReservesβ the sponsor starts paying reserves on behalf of the user.endSponsoringFutureReservesβ the sponsorship window closes.
The operations, step by step
When gasless trustline is enabled,/quote/build assembles a single SDEX transaction (built on the sponsorβs account as source) containing all of the operations below. For an EXACT_IN swap:
beginSponsoringFutureReservesβ sponsor starts sponsoring the userβs future reserves.changeTrustβ the user opens the trustline for the output asset (reserve paid by the sponsor).- (optional) Platform-fee payments β if
feeBps/referralIdare set. pathPaymentStrictSendβ the user performs the actual swap (assetInβassetOut).pathPaymentStrictReceiveβ the user buys 0.5 XLM using the output asset and sends it to the sponsor, repaying the reserve.endSponsoringFutureReservesβ the sponsorship window closes.
pathPaymentStrictReceive, or a plain payment when the input asset is XLM), then opens the trustline, then performs the main swap.
Using it in the API
Gasless Trustline touches two endpoints:/quote and /quote/build.
Step 1 β Request a gasless quote
AddgaslessTrustline: "create" to your /quote request body.
Only set
gaslessTrustline: "create" when you are sure the user does not already have a trustline for the output asset, and you have a funded sponsor account. If the user already trusts the asset, use a regular quote instead."platform": "sdex" and includes two extra objects:
Step 2 β Build the transaction
Pass the quote to/quote/build along with the user (from) and the sponsor account.
Requirements & limits
sponsoris required whengaslessTrustlineis set β the build fails without it.- The
fromandtoaddresses must currently be the same (a different recipient is not yet supported for gasless trustlines). - Gasless trustline works only on the Stellar Classic DEX (SDEX) and applies only to the userβs first swap for that asset.
Step 3 β Sign with both wallets, then send
Because the transaction spans the user and the sponsor, collect both signatures before submitting:- The user signs the XDR (opens the trustline, performs the swap, repays the sponsor).
- The sponsor signs the XDR (authorizes covering the reserve).
- Submit the fully-signed XDR to
POST /send(or through your own Soroban RPC / Horizon).
End-to-end example (JavaScript)
When to use it
β Use gasless trustline when:- The user is acquiring an asset for the first time (no existing trustline).
- You want the smoothest possible onboarding, especially for users with no XLM.
- You operate a funded sponsor account to front the reserve.
- The user already has a trustline for the output asset (use a regular quote β it will be cheaper and can route across all protocols, not just SDEX).
- You need to send the output to a different recipient than the swapper (
fromβtois not yet supported). - You want routing across Soroswap / Phoenix / Aqua β gasless trustline is SDEX-only.