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
feePayerAddresswithPOST /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.
Step 1: Get a quote with a sponsor
On your server, addfeePayerAddress 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’sunsignedTransaction 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.
POST /v1/execute. Thus, the sponsor’s signature is good only for this order.
Step 3: Your user signs
SendsponsoredTransaction 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
CallPOST /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.
Sponsor errors
See Errors for every other code.