Priority Fees Best Practices
Comprehensive guide to effectively implementing and optimizing priority fees for Solana transactions
Determining Appropriate Priority Fees
-
Use the Priority Fee API: Always use
getPriorityFeeEstimate
with therecommended: true
option to get a reasonable baseline fee based on current network conditions. -
Match transaction urgency to priority level:
Low
- Non-urgent transactions, can wait for confirmationMedium
- Standard priority, reasonable confirmation timeHigh
- Time-sensitive transactionsVeryHigh
- Critical transactions during high congestion
-
Adjust during network congestion: During high network activity, consider using higher priority levels to ensure timely processing.
-
Monitor performance: Track your transaction performance and adjust your priority fee strategy based on real-world results.
Transaction Configuration
-
Add compute budget instructions first: Always place compute budget instructions at the beginning of your transaction for proper processing.
-
Don’t overestimate compute unit needs: Request only the compute units your transaction actually requires to avoid wasting SOL.
-
Set maxRetries to 0 with staked connections: This ensures proper handling by the Helius infrastructure.
-
Update before sending: Always refresh the blockhash before signing and sending the final transaction.
Account-Based Estimates
-
Include all relevant accounts: For accurate estimates, include all writable accounts that will be part of your transaction.
-
Focus on writable accounts: The v2 algorithm primarily considers writable accounts, so prioritize including those in your account list.
-
Be aware of limitations: Account-based estimates don’t consider instruction-specific factors that might affect fees.
-
Handle sparse history: Use
evaluateEmptySlotAsZero: true
for accounts with infrequent activity.
Serialized Transaction Estimates
-
Always serialize the actual transaction: For accurate local fee market estimates, serialize the same transaction you’ll send, not a simplified version.
-
Include all actual instructions: The Priority Fee API works best when the serialized transaction includes all instructions (except the priority fee instruction itself).
-
Compare with account-based estimates: When possible, compare these estimates with account-based estimates to understand the differences.
-
Handle errors gracefully: The API may return errors if your transaction is malformed or contains invalid instructions.