Set your Solana swap’s compute unit limit near simulated usage, then choose a compute unit price from recent fees for the pool’s writable accounts. Start with a ready swap quote in a wallet or aggregator that exposes fee settings. Simulate the transaction, set the limit and price, send it, then use Solscan to confirm that the swap landed and the charged fee matches your calculation.
- Result: a confirmed swap with a fee you can account for.
- Needed: the swap transaction, adjustable fee settings, and access to recent fee samples.
How Do You Set Priority Fees for a Solana Swap?
- Review the quote and route before paying for speed. Confirm the token, output amount, slippage setting, and the pool the transaction will use; an aggregator may route through more than one pool. On a hyped Raydium launch, assess the token before raising your bid. A rugcheck is a review of a token for warning signs of a scam or rug pull; use it when deciding whether this particular swap is worth speeding up.
- Simulate the prepared swap to measure its compute use. A compute unit (CU) measures work performed by Solana programs. Read the simulation’s unitsConsumed value and confirm that its error field is empty. Use the transaction you intend to send, including its route and account setup instructions: changing those can change CU use. Say a Raydium swap consumes 210,000 CUs in simulation. That measurement gives you a starting point for its limit; a successful simulation also shows that the current route can execute against the state the RPC node saw.
- Set the compute unit limit slightly above that measurement. Solana’s compute budget guidance suggests a 10% margin, so the illustrative 210,000-CU swap would request 231,000 CUs. Set that value with the wallet’s custom limit field or a SetComputeUnitLimit instruction. The margin covers modest variation in execution. A limit below actual use causes a compute budget failure; a much larger limit increases the priority fee at every chosen CU price.
- Choose the compute unit price from recent transactions competing for the same accounts. Pass the swap’s writable pool accounts to getRecentPrioritizationFees; Solana’s RPC method returns recent samples for transactions that locked all supplied accounts as writable. An unfiltered network sample can understate the bid needed at a busy pool because Solana has local fee markets. Inspect recent nonzero samples, start near prices that have been landing for those accounts, and adjust for how quickly the quote must execute. A zero or old sample is a weak price target during a fast launch. Enter the selected value in micro-lamports per CU, or use SetComputeUnitPrice if you build the transaction yourself.
- Send the swap and inspect its signature on Solscan. Look for a successful result, the intended token movement, and the transaction fee. Compare the fee with your price and requested limit before placing another swap. If the transaction remains unconfirmed as its blockhash approaches expiry, refresh the quote and fee samples; the pool and its competing bids may have changed. A successful Solscan result with the expected fee completes this attempt.
Why Does a Larger Compute Unit Limit Cost More?
For legacy and v0 Solana transactions, the priority fee uses the requested limit, even when the swap consumes fewer CUs. Multiply the price in micro-lamports per CU by the limit, divide by 1,000,000, and round up to get lamports. Add the base fee of 5,000 lamports per signature. Solana’s fee specification defines this calculation. A v1 transaction instead sets an absolute priority fee in its message.
Continue the illustrative 231,000-CU swap with a price of 20,000 micro-lamports per CU. Its priority fee is 4,620 lamports; with one signature, its transaction fee is 9,620 lamports. Requesting 1,000,000 CUs at the same price makes the priority fee 20,000 lamports, although the swap still uses about 210,000 CUs. Trimming the limit saves 15,380 lamports in this attempt. The price is an illustrative input, not a current market quote: account congestion sets the useful bid.
- Confirm the quote and token risk.
- Simulate, then set a CU limit with a small margin.
- Price against recent fees for the route’s writable accounts.
- Send and verify the result and fee on Solscan.
Related Questions
Congestion, routing, and transaction validity affect whether a fee bid produces the intended swap.
Why do Solana transactions fail during congestion?
Congestion can leave a valid swap waiting behind transactions bidding for the same writable accounts until its blockhash expires. A swap that reaches execution can also fail because its CU limit is too low, its slippage threshold is breached, or pool state changed after simulation. Inspect the signature or preflight error before changing the fee: a higher bid addresses scheduling competition, while a changed route or limit addresses execution errors.
What is a Jito tip?
A Jito tip is a separate SOL payment used when submitting through Jito’s block engine, particularly for bundles competing in its auction. It is distinct from the Solana priority fee calculated from CU price and limit. Include it in your total spending decision when the selected route uses Jito, and review the tip alongside the transaction fee.
Does a higher priority fee guarantee inclusion?
No. A higher fee improves scheduling priority, while competing bids, available block capacity, delivery to a leader, blockhash validity, and swap execution still determine the outcome. Use fresh local samples and a valid simulated transaction; escalating the price alone cannot repair an expired quote or a failing swap instruction.
What Else Should You Check Before Sending?
MEV exposure and failure charges affect the value of a swap beyond its CU price.
What is MEV protection on Solana?
MEV protection limits the chance that another trader exploits your pending swap’s position in the execution order, such as by buying before it and selling after it. Use a tight, workable slippage setting and a protected submission route when your wallet offers one. Some protection methods apply only through a specific block engine, so inspect the route’s terms rather than treating a higher priority fee as protection.
Do priority fees get refunded on failure?
An on-chain transaction that executes and fails still pays its base and priority fees; its swap state changes are reverted. A transaction that never lands pays no on-chain transaction fee. Simulation also sends nothing and charges no on-chain fee. Distinguish a failed transaction shown on Solscan from an expired signature with no recorded transaction before deciding whether to retry.