Sign in

Transaction fees and compute units

Suggest an edit

A Solana transaction pays for two separate things. It pays a small fixed amount for the right to land in a block at all, and an optional extra amount for the leader to schedule it ahead of competing transactions. The first is the base fee, the second is the priority fee.

A fixed fee cannot tell transactions apart

The base fee is five thousand lamports per signature. A transaction with one signer pays five thousand lamports total in base fees. A transaction with two signers, say a multisig, pays ten thousand. The amount doesn't change with the size or complexity of what the transaction does. It exists to cover the cost of signature verification, which every validator has to perform, and to put a floor under spam. Half of the base fee gets burned, removed from circulation permanently. The other half goes to the validator that produced the block.

Before priority fees existed, this was the only fee, and the leader had no way to tell transactions apart. At five thousand lamports each, flooding the network was cheap, and in September 2021 bots chasing a token launch flooded it until block production stopped for seventeen hours, as told in Where Solana came from. Important transactions had no way to bid for inclusion ahead of the bot traffic. Adding the priority fee gave users a tool to express urgency and gave validators a signal for which transactions to favor.

The priority fee is a bid for earlier scheduling

The priority fee is on top of the base fee and is yours to set. It is the way a transaction tells the leader "schedule me ahead of the others." When the network is busy and more transactions arrive than fit in a block, the leader's scheduler sorts the incoming traffic by how much priority fee each transaction is paying per unit of computation, and works through them from highest to lowest. The priority fee goes entirely to the validator, none of it is burned.

Solana transaction fee split into base fee and priority feeTwo side-by-side panels compare the base fee (5,000 lamports per signature, always paid, 50% burned and 50% to the validator) with the priority fee (CU price times CU limit, optional, 100% to the validator, example totaling 200,000 lamports). Below them, total fee equals base fee plus priority fee, charged whether the transaction succeeds or fails. A Solana transaction fee has two parts 1. Base fee cost: 5,000 lamports per signature paid: always, every transaction where: 50% burned 50% to the validator For one signer: 5,000 lamports ≈ 0.000005 SOL paying this is what lets your transaction get into a block at all 2. Priority fee cost: CU_price × CU_limit / 1,000,000 paid: optional, zero is allowed where: 100% to the validator Example: 1,000 µlamports/CU × 200,000 CU = 200,000 lamports ≈ 0.0002 SOL paying this tells the leader to prioritize you over the queue of competing transactions total fee = base fee + priority fee Charged whether the transaction succeeds or fails. The leader did the work either way.

Both fees are paid up front, before the transaction runs. If the transaction fails, the network still keeps the fees and the state changes roll back.

The priority fee is charged on the compute unit limit

The value that determines the size of the priority fee is the compute unit, abbreviated CU. Every operation a Solana program performs costs a fixed number of compute units. Adding two integers, reading a byte from an account, calling another program, hashing some data, each one has a CU cost set by the runtime. The total CU consumption of your transaction is the sum across every operation it executes.

The CU limit is the cap your transaction declares for itself. It is the maximum number of compute units the runtime is allowed to spend on you before reverting the transaction with a "compute budget exceeded" error. Each transaction gets a default CU limit if you don't set one explicitly: 200,000 CU per instruction for programs you write (native Solana programs use a separate budget), up to a hard ceiling of 1,400,000 CU for the entire transaction.

The CU price is how many micro-lamports you are willing to pay per compute unit of that budget. A micro-lamport is one millionth of a lamport, so the formula divides by a million to turn it back into whole lamports: priority_fee = CU_price × CU_limit / 1,000,000.

The priority fee is computed from the CU limit, the cap you reserved, rather than from the CU usage, what the program actually spent. If you reserve 200,000 CU and your program only uses 60,000, you still pay priority fee on all 200,000. The leader treats the cap as the resource you locked up, since they had to plan for it being used. On Ethereum the gas you reserve and do not use is refunded, as the contracts and gas lesson describes.

Compute units: budget vs actual, priority fee charged on the 200,000 CU capThe diagram compares a 200,000 CU compute budget with the 60,000 CU the program actually used, leaving 140,000 CU unused but still reserved. It shows the priority fee is charged on the full 200,000 CU cap, with an example: at 1,000 microlamports per CU, the fee is 200,000 lamports. Compute units: budget vs actual your transaction's CU budget (what you asked for) 200,000 CU the cap your transaction will pay for what the program actually used 60,000 CU 140,000 CU unused but reserved priority fee charged on what you asked for, the 200,000 cap if CU_price = 1,000 µlamports/CU: priority fee = 1,000 × 200,000 / 1,000,000 = 200,000 lamports setting the limit too high wastes lamports. setting it too low reverts the transaction. Pick a limit that fits your program's actual usage with a small margin. Default is 200,000 per instruction.

The leader fills the block from the highest bid down

Picture three transactions arriving at the same leader in the same block. Alice's transaction is paying 5,000 micro-lamports per CU, Bob's is paying 100, and Carol's is paying zero. All three have the default 200,000 CU limit.

Alice's priority fee comes out to 5,000 × 200,000 / 1,000,000 = 1,000 lamports, Bob's to twenty lamports, and Carol's to zero. The leader's scheduler sorts incoming transactions by priority fee per CU, fills the block from the top of the sorted list, and stops when the block is full. Alice lands first, Bob second if there is room, Carol last or not at all depending on how much demand the leader is seeing.

Priority fee market: Alice, Bob, and Carol ranked by fee per CUThree sample transactions from Alice, Bob, and Carol show different priority fees per compute unit, from highest to zero. The leader's scheduler sorts them by fee per CU and fills the block from the top, so Alice lands first, Bob lands second if there is room, and Carol lands last or not at all. The priority fee market: leaders pick the highest bidders first Tx from Alice CU_limit: 200,000 CU_price: 5,000 µL priority fee 1,000,000 lamports Tx from Bob CU_limit: 200,000 CU_price: 100 µL priority fee 20,000 lamports Tx from Carol CU_limit: 200,000 CU_price: 0 µL priority fee 0 lamports Leader's scheduler sorts by priority fee per CU block space is finite, so the highest bidders go first Block order 1. Alice 5,000 µL/CU → included first, fast confirmation 2. Bob 100 µL/CU → included if block has room 3. Carol 0 µL/CU → included only if nothing else is waiting Carol still pays the base fee. She just doesn't get prioritized. When the network is quiet, even 0 µL/CU lands quickly. When it's congested, the fee market wakes up.

Two transactions whose writable accounts do not overlap can run side by side, as the instructions and transactions lesson showed, but transactions that write to the same account run one after another. If thousands of transactions want to write to the same account, for example the pool of a token that just launched, they form a queue for that account, and the priority fee per CU decides the order in it. A transfer between two unrelated wallets writes to different accounts and does not wait in that queue. On Ethereum every transaction in a block pays the same base fee per unit of gas, and the protocol raises it when blocks are more than half full, so one busy contract raises the fee for unrelated transactions too.

Budget compute on every transaction

The Compute Budget program is what you use to set the CU limit and the CU price. It is a built-in Solana program with two instructions you will use: SetComputeUnitLimit to set the CU cap, and SetComputeUnitPrice to set the per-CU rate. You include them in your transaction alongside your real work, and the runtime reads them before execution to size your budget.

Set the CU limit too high and every transaction pays priority fee on compute units it never touches, which adds up across thousands of transactions and, worse, dilutes your effective bid per CU so the leader treats you as a lower priority than you thought. Set it too low and the transaction reverts mid-execution with a compute budget error, and you still pay the fee with no result. The right move is to simulate your transaction first, see how many CUs it actually consumes, add a margin of ten or twenty percent, and set the limit to that. Programs change as you develop them, and a margin that was right last month may be wrong this month. The price comes from looking at what the network is currently paying for prompt inclusion, which you fetch from your RPC provider or estimate from recent blocks.

When you write a program, you make its CU consumption a number you care about. Cheap programs cost less in priority fees per execution, which matters when users run them millions of times.