BLOG
Fundementals

How to land transactions on Solana

Ory

Ory

Sep 1, 2024 • 4 min read



We've compiled the best practices when sending transactions on the Solana network to help you optimize performance, reduce latency, and improve the overall user experience of your application.

Manage Retries in Your Client or Backend

To ensure more predictable transaction delivery and enhance user experience, it's recommended to handle transaction retries within your client or backend system rather than relying on the RPC retry service.

  • Set maxRetries: 0 when sending transactions.

By doing so, you prevent the RPC nodes from retrying transactions on your behalf, giving you full control over the retry logic and avoiding potential delays caused by saturated RPC queues.

Simulate Transactions Separately Before Sending

Simulating transactions can help you catch errors before sending, but it can also slow down transaction confirmations if not handled properly.

  • Use simulateTransaction() in a separate RPC call before sending the actual transaction.

  • Include skipPreflight: true when sending the transaction to bypass preflight checks.

By simulating transactions separately, you enable more delivery routes that can speed up confirmations. Traders often skip simulations to save valuable milliseconds.

Use Reliable Blockhashes

Using the correct blockhash with the appropriate commitment level is crucial for transaction reliability.

  • Obtain blockhashes using a finalized commitment level for maximum reliability.

  • Using confirmed commitment works as well.

  • Avoid using processed commitment for blockhashes.

Ensure that the commitment level of your connection for sendTransaction() matches the blockhash's commitment level to prevent inconsistencies.

Optimize Compute Unit (CU) Budgets

Setting an accurate Compute Unit (CU) budget helps validators efficiently pack your transaction into blocks, especially when space is limited.

  • Adjust the CU budget to match the actual requirements of your transaction.

  • The default CU budget is often higher than necessary.

For reference:

  • A simple SOL transfer requires approximately 500 CUs.

  • A token transfer requires approximately 5,000 CUs.

Include Priority Fees Wisely

Priority fees are essential for getting your transactions processed promptly, but overpaying doesn't necessarily yield better results.

  • Even a small priority fee (as little as 1 lamport) can be sufficient.

  • Check the prevailing rates for your writable accounts to set an appropriate fee.

Use the improved priority fees API to identify fees at different percentiles. Setting your priority fee slightly below the median value is generally effective. Avoid excessively high priority fees to conserve resources.

Avoid Relying on RPC Retries

During periods of network congestion, relying on RPC nodes to retry transactions can lead to delays and unpredictability.

Understanding Backpressure

"Backpressure" occurs when the network receives more transaction requests than it can handle, leading to queues on RPC nodes. This can saturate the queues, preventing RPCs from sending new transactions effectively.

The Solution

  • Implement retry logic within your application to handle transaction resubmissions.

  • Include maxRetries: 0 with sendTransaction() to disable RPC retry queues.

By taking control of the retry mechanism, you reduce dependency on RPC nodes and improve transaction delivery predictability.

Conclusion

By following these best practices, you can enhance the efficiency and reliability of transactions on the Solana network. Managing retries within your application, simulating transactions separately, using reliable blockhashes, optimizing CU budgets, and setting appropriate priority fees are key steps toward a more performant and user-friendly application.