Toolbox

Priority Fees and Compute Management

The Compute Budget Program allows us to set a custom Compute Unit limit and price. You can read more about this program in Solana's official documentation.

Set Compute Unit limit

This instruction allows you to set a custom Compute Unit limit for your transaction.

import { transactionBuilder } from '@metaplex-foundation/umi'
import { setComputeUnitLimit } from '@metaplex-foundation/mpl-toolbox'

await transactionBuilder()
  .add(setComputeUnitLimit(umi, { units: 600_000 })) // Set the Compute Unit limit.
  .add(...) // Any instruction(s) here.
  .sendAndConfirm(umi)

Set Compute Unit price / Priority Fees

This instruction allows you to set a custom price per Compute Unit for your transaction

import { transactionBuilder } from '@metaplex-foundation/umi'
import { setComputeUnitPrice } from '@metaplex-foundation/mpl-toolbox'

await transactionBuilder()
  .add(setComputeUnitPrice(umi, { microLamports: 1 })) // Set the price per Compute Unit in micro-lamports.
  .add(...) // Any instruction(s) here.
  .sendAndConfirm(umi)

Guide how to calculate units and microLamports

To be able to choose proper numbers for microLamports and units there was a small guide created that walks through different RPC calls that can be used for calculation.

Previous
Token Managment