getTransactionMessageComputeUnitPrice

function getTransactionMessageComputeUnitPrice<TTransactionMessage>(
    transactionMessage,
): bigint | undefined;

Returns the compute unit price currently set on a legacy or v0 transaction message, or undefined if none is set.

This searches the instructions for a SetComputeUnitPrice instruction and decodes its value. The value represents the price in micro-lamports per compute unit.

Type Parameters

Type Parameter
TTransactionMessage extends TransactionMessage & object

Parameters

ParameterTypeDescription
transactionMessageTTransactionMessageThe legacy or v0 transaction message to inspect.

Returns

bigint | undefined

The compute unit price in micro-lamports per compute unit, or undefined if none is set.

Example

const price = getTransactionMessageComputeUnitPrice(transactionMessage);
if (price !== undefined) {
    console.log(`Compute unit price: ${price} micro-lamports`);
}

See

On this page