in-solana by Supanode

Compute Budget Program — Instructions

ComputeBudget111111111111111111111111111111

The Compute Budget Program is a native Solana program that controls transaction resource allocation. It sets the compute unit limit, compute unit price (priority fee), heap frame size, and loaded accounts data size limit for a transaction.

Program ID

ComputeBudget111111111111111111111111111111

Instructions

Each instruction type can appear at most once per transaction. Duplicates cause the transaction to fail.

InstructionDiscriminatorParameterDescription
SetComputeUnitLimit2units: u32Sets the maximum compute units the transaction may consume. Capped at 1,400,000 CUs per transaction
SetComputeUnitPrice3micro_lamports: u64Sets the compute unit price in micro-lamports for calculating the priority fee
RequestHeapFrame1bytes: u32Requests a heap size between 32 KiB and 256 KiB, must be a multiple of 1,024
SetLoadedAccountsDataSizeLimit4bytes: u32Sets the maximum total bytes of account data the transaction may load. Capped at 64 MiB

Default limits

ResourceDefaultMaximum
Compute units per instruction200,000—
Compute units per transaction200,000 × number of instructions1,400,000
Builtin instruction CU cost3,000—
Heap size32 KiB256 KiB
Loaded accounts data64 MiB64 MiB

Priority fee calculation

The priority fee is calculated as:

priority_fee = ceil(compute_unit_price × compute_unit_limit / 1,000,000) lamports

Setting a lower compute_unit_limit reduces the priority fee for the same compute_unit_price. Use simulateTransaction to estimate actual CU consumption, then set the limit slightly above that value.

FAQ

Do I always need Compute Budget instructions? No. Without them, the transaction uses default values (200,000 CUs per instruction, 0 priority fee). Add them when you need a higher limit for complex transactions or want to set a priority fee during congestion.

What happens if my transaction exceeds the compute unit limit? The transaction fails with a “computational budget exceeded” error. The priority fee is still charged.

Is the Compute Budget Program upgradeable? No. It is a native program built into the Solana runtime.

Updated: