Skip to main content
This feature is in private alpha and the details are subject to change!
You can pay the gas for your users’ trades from a wallet you control. Your wallet, the sponsor, pays the transaction fee and the account rent. Your user’s wallet needs no SOL. This works only on the rfq-fill route, for tokenized stocks against USDC on Solana. See RFQ orders for how that route works. This recipe builds on the swap recipe and the RFQ orders recipe. It uses the same headers, wallet, account, and signing code.

How it works

  • Your server sends feePayerAddress with POST /v1/quotes. The quote’s transaction then names the sponsor as its fee payer.
  • Your server signs the quote’s transaction with the sponsor first. Then your user signs it.
  • You send the transaction with both signatures to POST /v1/execute.
  • The order’s rent returns to the sponsor when the order closes.
Never sign a transaction that your user or your app sends to your server. The sponsor signs only the unsignedTransaction from the quote that your server got itself. A sponsor signature on any other transaction can spend the sponsor’s SOL.

Step 1: Get a quote with a sponsor

On your server, add feePayerAddress to the quote request from RFQ orders:
A request with a sponsor gets quotes only from rfq-fill. Other routes can’t use a separate fee payer, so they’re skipped and listed in unavailableRoutes with the code fee_payer_not_supported. If rfq-fill gives no quote, unavailableRoutes says why. A feePayerAddress equal to fromAddress has no effect. Your user pays their own gas, as on a request without it. The sponsor wallet needs enough SOL for the transaction fee and the rent of the order’s accounts. Sunrise screens the sponsor wallet the same way as your user’s wallet, on the quote and on execute.

Step 2: The sponsor signs

On your server, sign the quote’s unsignedTransaction with the sponsor. Keep the sponsor’s key on your server, not in your app. Check that the sponsor is the transaction’s fee payer, the first signer, before you sign.
The sponsor signs the transaction exactly as quoted, with the quote’s priority fee. The transaction can’t land without the solver’s signature, which Sunrise adds only through POST /v1/execute. Thus, the sponsor’s signature is good only for this order.

Step 3: Your user signs

Send sponsoredTransaction to your app. Ask your user’s wallet to sign it, as in step 3 of RFQ orders. The wallet adds your user’s signature next to the sponsor’s. If the wallet changes the transaction when it signs, for example its priority fee, the sponsor’s signature no longer matches and the order fails to land. Get a new quote, and sign it with a wallet that signs the transaction unchanged.

Step 4: Execute

Call POST /v1/execute with the transaction that both wallets signed, and track the order as in RFQ orders. Nothing else changes for a sponsored quote. If the sponsor’s signature is missing, execute returns 400 invalid_transaction and sends nothing. The quote stays usable until expiresAt. Sign the quote’s unsignedTransaction with the sponsor and start again from step 2. See Errors for every other code.