setTransactionMessageComputeUnitPrice

function setTransactionMessageComputeUnitPrice<TTransactionMessage>(
    computeUnitPrice,
    transactionMessage,
): TTransactionMessage;

Sets the compute unit price for a legacy or v0 transaction message.

The value represents the price in micro-lamports per compute unit. The actual priority fee paid is computeUnitPrice × computeUnitLimit.

This appends, replaces, or removes a SetComputeUnitPrice instruction from the Compute Budget program. The operation is idempotent: setting the same value returns the same reference, and setting undefined removes the instruction.

Type Parameters

Type ParameterDescription
TTransactionMessage extends TransactionMessage & objectThe transaction message type.

Parameters

ParameterTypeDescription
computeUnitPricebigint | undefinedThe price in micro-lamports per compute unit, or undefined to remove the instruction.
transactionMessageTTransactionMessageThe legacy or v0 transaction message to configure.

Returns

TTransactionMessage

A new transaction message with the compute unit price set.

Example

const txMessage = setTransactionMessageComputeUnitPrice(
    10_000n,
    transactionMessage,
);

See

On this page