Transaction Fees

Every Solana transaction requires a base fee (SOL) to compensate validators for processing the transaction. You can also pay an optional prioritization fee to increase the chance that the current leader (validator) processes your transaction.

Key Points

  • The base fee for a transaction is 5000 lamports per signature on the transaction.
  • The prioritization fee (optional) is an extra fee you pay to the validator to increase the chance that the current leader processes your transaction.
  • The prioritization fee equals: (compute unit limit * compute unit price).
  • The compute unit limit is the maximum compute units your transaction can use.
  • The compute unit price is the price per compute unit, in micro-lamports.
  • 1,000,000 micro lamports = 1 lamport
  • The transaction fee payer must be an account owned by the System Program.

Base Transaction Fee

The base fee is the cost to send a transaction. The cost is 5000 lamports per signature included in the transaction.

The base fee comes out of the transaction fee payer's account, which is the first signer on the transaction. The fee payer must be an account owned by the System Program.

Prioritization Fee

The prioritization fee is an optional fee paid to increase the chance that the current leader processes your transaction.

  • SIMD-0096: The validator processing the transaction receives 100% of the priority fee.

Compute Units and Limits

When a transaction is processed, it uses computational resources measured in compute units (CU). Each instruction deducts from the transaction's compute unit budget.

  • Max Limit: A transaction can use up to 1.4 million compute units.
  • Default Limit: By default, each instruction can use up to 200,000 compute units.
  • Custom Limit: You can request a specific compute unit limit by including a SetComputeUnitLimit instruction in your transaction.

For more details on compute unit usage:

See the How to Request Optimal Compute guide for more details on compute unit usage.

Compute Unit Price

The compute unit price is an optional amount, specified in micro-lamports, that you pay for each compute unit requested. This price is used to calculate the prioritization fee for your transaction.

1,000,000 micro lamports = 1 lamport

Use these resources to get real-time recommendations on the current compute unit price:

See the How to Use Priority Fees guide for more details on priority fees.

Calculate Prioritization Fee

The prioritization fee is calculated as:

Prioritization Fee = Compute Unit Limit × Compute Unit Price

Use these instructions to set the compute unit limit and price on a transaction:

If you don't provide these instructions, the transaction uses the default compute unit limit with a compute unit price of 0 (no prioritization fee).

The priority fee depends on the compute unit limit you request for the transaction, not the actual compute units used. If you set a compute unit limit that's too high or use the default amount, you might pay for unused compute units.

Examples

The following examples show how to set the compute unit limit and price for a transaction.

SDKSource Code Reference
solana-sdk (Rust)ComputeBudgetInstruction
@solana/web3.js (Typescript)ComputeBudgetProgram
const limitInstruction = ComputeBudgetProgram.setComputeUnitLimit({
units: 300_000
});
const priceInstruction = ComputeBudgetProgram.setComputeUnitPrice({
microLamports: 1
});
import {
LAMPORTS_PER_SOL,
SystemProgram,
Transaction,
Keypair,
Connection,
ComputeBudgetProgram,
sendAndConfirmTransaction
} from "@solana/web3.js";
const connection = new Connection("http://localhost:8899", "confirmed");
const sender = Keypair.generate();
const recipient = new Keypair();
const airdropSignature = await connection.requestAirdrop(
sender.publicKey,
LAMPORTS_PER_SOL
);
await connection.confirmTransaction(airdropSignature, "confirmed");
// Create compute budget instructions
const limitInstruction = ComputeBudgetProgram.setComputeUnitLimit({
units: 300_000
});
const priceInstruction = ComputeBudgetProgram.setComputeUnitPrice({
microLamports: 1
});
const transferInstruction = SystemProgram.transfer({
fromPubkey: sender.publicKey,
toPubkey: recipient.publicKey,
lamports: 0.01 * LAMPORTS_PER_SOL
});
// Add the compute budget and transfer instructions to a new transaction
const transaction = new Transaction()
.add(limitInstruction)
.add(priceInstruction)
.add(transferInstruction);
const signature = await sendAndConfirmTransaction(connection, transaction, [
sender
]);
console.log("Transaction Signature:", signature);

Click 'Run' to see output.
Program Logs in the Output are clickable links to Solana Explorer.
You must enable the "Enable Custom URL Param" setting on Solana Explorer.
If not enabled, links will default to localhost:8899 instead of the Mirror.ad RPC URL.

Is this page helpful?

Table of Contents

Edit Page