Solana: Analyzing adjacent transactions for priority fees
TLDR
- This Python script inspects the fee usage in blocks adjacent to your own target transaction on Solana, focusing on the same on-chain program.
- It decodes compute budget instructions (priority fees) to show both your transaction’s fee and those of other transactions in nearby blocks.
- By comparing priority fees, you can tune your own transaction fees to optimize speed or cost, and troubleshoot performance.
- Useful for pump.fun or any scenario where outbidding other participants at the block level is crucial.
Main article
This guide shows you how to analyze transaction priority fees for transactions adjacent to your target transaction on Solana. This is particularly useful when developing trading strategies or troubleshooting transaction execution on programs like pump.fun.
What the script in this tutorial does is look for transactions adjacent to the one you specify (usually your own) and checks all other transactions involving the same program and prints the priority fees in the same block and the adjacent blocks to easily see how your particular transaction stacks up and how you can tune it to win more races.
Prerequisites
Get you own node endpoint today
Start for free and get your app to production levels immediately. No credit card required.
You can sign up with your GitHub, X, Google, or Microsoft account.
- Python 3.7+
- Packages:
pip install solana base58
Understanding Solana fees
The recommended reading list:
- How to use Priority Fees to unlock faster transactions
- Estimate Priority Fees with getRecentPrioritizationFees
- Solana Trader nodes
- Or the official Solan docs: Fees on Solana.
Implementation
If you end up in this specific scenario as outlined in the beginning of the article, here’s things that you need to have to get the results:
- A program address that you are interacting with to get the races simply won or tactically won (like trying to get your transaction execution at a certain place in the race instead of trying to be first), or simply how much on an edge you need to be the first. Which you can also do with How to use Priority Fees to unlock faster transactions and Estimate Priority Fees with getRecentPrioritizationFees as mentioned.
- A transaction signature — this can be the signature of your transaction of a transaction of an account that you get through your own humint ways.
The script itself:
In the script:
- PROGRAM_ID — set to the pump.fun executable. Set it to any executable on-chain program you interact with.
- COMPUTE_BUDGET_ID — set to the Solana system program responsible for compute units and fees. We use in the script to find and decode the priority fees.
- RPC_URL — tour Chainstack Solana node endpoint.
- SIGNATURE — the transactions signature (hash) around which you want to analyze similar transactions.
- SLOTS_BACK — number of slots to travel back from the slot where you transaction landed (was included in the block).
- SLOTS_FORWARD — number of slot to travel forward to see who used what fees after you transaction landed.
To use the script, just run python check_adjacent.py
or whatever you name it.
Example output:
Use cases
This tool is particularly useful for:
- Analyzing competitor trading strategies
- Optimizing your own priority fees
- Troubleshooting failed transactions
- Understanding market competition in specific slots
- Developing automated trading systems
Conclusion
Understanding transaction priority fees and their impact on execution is crucial for successful trading on Solana. This tool helps you analyze the competitive landscape and optimize your trading strategy by providing insights into how other traders are setting their priority fees.
For more Solana development tools and guides, see Mastering Solana.