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.
| Instruction | Discriminator | Parameter | Description |
|---|---|---|---|
SetComputeUnitLimit | 2 | units: u32 | Sets the maximum compute units the transaction may consume. Capped at 1,400,000 CUs per transaction |
SetComputeUnitPrice | 3 | micro_lamports: u64 | Sets the compute unit price in micro-lamports for calculating the priority fee |
RequestHeapFrame | 1 | bytes: u32 | Requests a heap size between 32 KiB and 256 KiB, must be a multiple of 1,024 |
SetLoadedAccountsDataSizeLimit | 4 | bytes: u32 | Sets the maximum total bytes of account data the transaction may load. Capped at 64 MiB |
Default limits
| Resource | Default | Maximum |
|---|---|---|
| Compute units per instruction | 200,000 | — |
| Compute units per transaction | 200,000 × number of instructions | 1,400,000 |
| Builtin instruction CU cost | 3,000 | — |
| Heap size | 32 KiB | 256 KiB |
| Loaded accounts data | 64 MiB | 64 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: