Transaction Fees

Every Solana transaction requires a base fee (SOL) to compensate validators for processing the transaction. An optional prioritization fee is also available to increase the probability that the transaction is processed by the current leader (validator).

Key Points

  • The base fee for a transaction is a minimum of 5000 lamports per signature on the transaction.
  • The prioritization fee (optional) is an additional fee paid to the validator to increase the probability that the transaction is processed.
  • The prioritization fee is calculated as: (compute unit limit * compute unit price).
  • The compute unit limit is the maximum number of compute units that the transaction can consume.
  • 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 minimum cost to send a transaction. The cost is a minimum of 5000 lamports per signature, with a target of 10000 lamports per signature.

The base fee is automatically paid for by the transaction fee payer, 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 the validator to increase the probability that the transaction is processed.

  • SIMD-0096: 100% of the priority fee is paid directly to the validator processing the transaction.

Compute Units and Limits

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

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

For additional details into compute unit usage:

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

Compute Unit Price

The compute unit price, denominated in micro lamports, is the optional price paid per compute unit to calculate the prioritization fee.

1,000,000 micro lamports = 1 lamport

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

Refer to 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 the following instructions to set the compute unit limit and price on a transaction:

If these instructions are not provided, the transaction automatically uses the default compute unit limit with a compute unit price of 0 (no prioritization fee).

The priority fee is based on the compute unit requested for the transaction, not the actual compute units used by the transaction. If you set a compute unit limit that is too high or use the default amount, you may be paying for unused compute units.

Examples

Below are examples of the instructions used to set the compute unit limit and price for a transaction.

Rust

The solana-sdk provides methods through the ComputeBudgetInstruction type:

let limit_instruction = ComputeBudgetInstruction::set_compute_unit_limit(300_000);
let price_instruction = ComputeBudgetInstruction::set_compute_unit_price(1);

JavaScript

The @solana/web3.js library (v1) provides methods through the ComputeBudgetProgram class:

const limitInstruction = ComputeBudgetProgram.setComputeUnitLimit({
units: 300_000,
});
const priceInstruction = ComputeBudgetProgram.setComputeUnitPrice({
microLamports: 1,
});

Mục lục

Chỉnh sửa trang