Skip to main content
Use sponsored swaps to build gasless trading features where users swap tokens without holding SOL for fees. A sponsor pays the transaction fee and token account creation costs on the user’s behalf. To create a sponsored swap, pass the sponsor parameter with the sponsor’s wallet address on a Trade API request. Both the user and sponsor must sign the resulting transaction.

Why Use User-Executed Sponsored Swaps

  • Smaller transactions. Eliminates the input transfer to the sponsor and output transfer back to the user, reducing overall transaction size.
  • Simpler transaction structure. The user swaps directly from their own token accounts in a single step.

Execution Modes

Execution modes determine who performs the swap. The sponsor performs the swap on the user’s behalf:
  1. User transfers input tokens to sponsor.
  2. Sponsor executes the swap using their token accounts.
  3. Sponsor transfers output tokens to user.

User Executes

The user performs the swap directly using their own token accounts. The sponsor still pays the transaction fee and token account creation costs.

Parameters

The sponsor’s wallet address. When specified, the sponsor pays the transaction fee and token account creation costs. Base58-encoded.

sponsoredSwap

Set to true to indicate the swap will be sponsored. This ensures the quote accounts for the correct transaction structure and fees based on the execution mode. Not needed on /order or /swap — those endpoints infer sponsorship from the sponsor parameter.

sponsorExec

Choose who executes the swap in a sponsored transaction. Pass this parameter on three endpoints:
  • GET /order — query parameter, used when sponsor is specified.
  • GET /quote — query parameter, used when sponsoredSwap is true.
  • POST /swap — request body field, used when sponsor is specified.

Code Examples