Understanding Solana gas fees settings Compute Budget: SetComputeUnitPrice & SetComputeUnitLimit
In this article i make an attempt to make understandable the different variables involved in setting the transaction gas fees for a solana transaction. If you have been confused about this as much as I have been then this might be helpful
Formulae for calculation of solana gas fees
Fees_in_MicroLamports= Compute Unit Price X Compute Limit
1Mircro_to_Lamport = 0.000001
Fees_in_Lamport= Fees_in_MicroLamports * 1Micro_To_Lamports
Basic unit fee for each transaction in sol = .000005
Basic Unit fee in lamports = 5000
Txn_total_Lamports=Fees_inLamports + Basic Unit fee in Lamport
1Lamport= 0.000000001Sol
Final fees in lamports = Txn_total_Lamports * 1Lamport
So to make the math above clear let’s have a practical example
Let’s assume we are having the following variables for our gas fees settings;
SetComputeUnitPrice= 1_073
SetComputeUnitLimit=200_000
200000 * 1073 = 214,600,000 (MicroLamports)
1MicroLamports = 0.000001Lamports
214,600,000ML * 0.000001 = 214.6 Lamports
Basic Fee = 0.000005 SOL
0.000005 + 0.000002146 = 0.0000052146 SOL
1 Lamports = 0.00000001// Minimum unit
Round up the fraction from the smallest unit
Final Fee = 0.00005215 SOL
I hope this article helps you in clarifying the mathematics behind solana transactions fees.