Sponsored Swaps
Set sponsor in your /solana/swap-instructions request to a wallet your app controls. That wallet pays the transaction fee and the rent for every account the swap creates. The taker still signs the transaction and keeps full control of their tokens; the sponsor never holds them.
When you build the transaction, make the sponsor the fee payer and collect signatures from both the sponsor and the taker. The response echoes sponsor to confirm the request was sponsored.
If the API cannot build a swap that the sponsor fully pays for, it returns an error. It never falls back to a transaction where the taker pays.
What the sponsor pays
Some costs come back to the sponsor in the same transaction. The rest are spent.
Returned in the same transaction
Spent
Rent depends on the account size and the network’s current rate; getMinimumBalanceForRentExemption returns it. Token-2022 accounts cost more when the mint has extensions.
Protection against rent farming
A sponsor that pays rent for accounts someone else can close is open to abuse: a user could close the account and keep the rent, again and again. The API and the settlement program prevent this:
- The taker’s new output token account gets the sponsor as its close authority, so only the sponsor can reclaim its rent.
- Wrapped SOL output is not allowed with a sponsor, because a wrapped SOL account cannot safely be given a close authority. Request native SOL output instead.
- A wrapped SOL fee recipient must be an existing token account; the sponsor will not create one.
- Temporary accounts must be closed in the same transaction, or the swap fails.
- The swap fails if the sponsor ends up paying more than the costs listed above.
Accounts created from an owner destination belong to that owner, who can close them and keep the rent. Use the owner form only for addresses you control, such as your own fee wallet. If your users choose recipient, require an existing token account or leave recipient unset.
Requirements
The API rejects a sponsored request when:
sponsoris the taker, or any address in the request that receives native SOL.- The output is wrapped SOL.
- A token account given as a plain address for the output or a fee does not exist, or holds a different token.
- A native SOL fee or surplus recipient does not already hold the rent-exempt minimum.
- For native SOL output, the destination’s balance plus
min_amount_outwould stay below that minimum.