Skip to main content
5 votes
Accepted

How do I parse TransactionInstruction in new web3.js?

The legacy TransactionInstruction type has this shape: { data: Buffer; keys: Array<{isSigner: boolean, isWritable: boolean, pubkey: PublicKey}>; programId: PublicKey; } The new ...
steveluscher's user avatar
  • 3,153
5 votes
Accepted

How to programmatically find the amount of compute units used in a transaction?

getTransaction JSON-RPC method returns an object with transaction metadata with computeUnitsConsumed field. Examples on how you can get the amount of compute units used in a transaction In JS: const ...
acheron's user avatar
  • 2,909
5 votes
Accepted

What is the minimum amount of CUs a Solana transaction must process?

Depends on how deep you want to go. I won't be able to give an exact number, but hopefully a picture can be painted here. Theoretically the very minimum would be 1 CU (to my knowledge every ...
Joey Meere's user avatar
  • 1,612
4 votes

What is the minimum amount of CUs a Solana transaction must process?

If your program just calls exit, then it's possible for the program to only take 1 CU. Currently, there's no CU cost to instruction data, loading account data, or taking write locks, but that might ...
Jon C's user avatar
  • 19.6k
4 votes
Accepted

How to increase compute_budget?

try using this inplace of set_compute_limit ComputeBudgetInstruction::RequestUnitsDeprecated(1_400_000u32);
Nabeel Naveed's user avatar
4 votes
Accepted

How to set Compute Limit and Compute Unit Price using Python

The idea is that the compute limit and compute limit price are instructions. And from the Jupiter API we already get a transactions object. Thus we have to add these priority fee instructions to the ...
sashavsthewrld's user avatar
4 votes

How Many CUs are used by ComputeBudgetProgram?

Edit: 150 CUs are consumed by the ComputeBudget program, per https://github.com/solana-labs/solana/blob/a36e1b211d144f3cf0f2a6f68da7600b49454c1a/runtime/src/block_cost_limits.rs#L45 It will also fail ...
Jon C's user avatar
  • 19.6k
4 votes

How to Increase compute limit above 200k compute

https://solanacookbook.com/references/basic-transactions.html#how-to-change-compute-budget-fee-priority-for-a-transaction Use ComputeBudgetProgram.setComputeUnitLimit({ units: number }) to set the ...
john's user avatar
  • 7,794
3 votes
Accepted

How to convert a MessageCompiledInstruction to TransactionInstruction in web3.js

If you have a versioned transaction, you can get the instructions of that transaction by let ixs = TransactionMessage.decompile( versionedTx.message ).instructions; The AccountMeta ...
Jimii's user avatar
  • 7,712
3 votes
Accepted

How does the Solana BPF VM calculate how many Compute Units a program consumes?

You've done your research really well! You're correct on everything. syscalls have costs that are defined in the compute budget BPF instructions all consume 1, as seen as https://github.com/solana-...
Jon C's user avatar
  • 19.6k
3 votes

How to Increase compute limit above 200k compute

I haven't really found great docs on it, but I believe the way it works is that your transaction's first instruction must be this: https://github.com/solana-labs/solana/blob/...
HelmetFace's user avatar
  • 1,807
3 votes

How do you split a function call across multiple instructions? (How can I get around the compute limit)

To do compute over multiple instructions you can store intermediate calculations in variables on an account. That way when you start up the next transaction you can continue on from where you finished ...
Henry E's user avatar
  • 2,949
3 votes
Accepted

How do you split a function call across multiple instructions? (How can I get around the compute limit)

That will very much depend on the code you want to run in the instruction, of course. Is it code you wrote yourself, or are you mostly calling function from some library? You would have to find ways ...
AllBlooming's user avatar
  • 2,309
3 votes
Accepted

Error downloading the ComputeBudget program to use on local validator

I tried running an example similar to this one and it works for me. My only idea is that your local validator isn't up to date. You can run solana validators to check which version are most validators ...
pepeIKO's user avatar
  • 416
3 votes
Accepted

Are writes to BTreeMaps expensive? How much compute units does it take?

It depends on what you mean by "write" as not all writes are equal. For example, it will be expensive if you grow the BTreeMap inside a loop but it won't be expensive if you mutate one of it'...
acheron's user avatar
  • 2,909
3 votes

How are additional costs calculated with the `requestHeapFrame` instruction?

The requestHeapFrame instruction adds an additional 8 compute units per 32K heap requested. This means if you have a compute budget instruction for requestHeapFrame and use SetComputeUnitPrice to set ...
Jacob Creech's user avatar
  • 4,019
2 votes
Accepted

Does requesting more compute units increase the fee for a transaction?

From (https://docs.solana.com/proposals/comprehensive-compute-fees), eventually there will be some multiple of lamports applied per bpf Compute Unit: "The compute budget portion of the fee will ...
Whiteseal's user avatar
  • 3,607
2 votes

How to Add ComputeBudget into Versioned Transaction?

You can this code: const ix_1 = solana.ComputeBudgetProgram.setComputeUnitLimit( { units: 300_000 } ); const ix_2 = solana.ComputeBudgetProgram.setComputeUnitPrice( { ...
pooria sarkhan's user avatar
2 votes

How to Add ComputeBudget into Versioned Transaction?

Finally I could solve the issue by this way; const instruction = await program.methods.breedBee(false) .accounts({list of accounts}) .signers([ list of signers]) ....
Siavash Soleimanpour's user avatar
2 votes
Accepted

Where can I find how many CUs different operations and syscalls cost?

Found my answer in the end, the CU amount per syscall can be found in the codebase here.
McBain's user avatar
  • 5,384
2 votes
Accepted

Does the order matter when submitting a increase compute budget instruction

It does not. If you check the compute budget calculation code here you can see it iterates through all instructions to find the ones that set the CU Limit and CU Price.
McBain's user avatar
  • 5,384
2 votes
Accepted

How is priority fee calculated for this example?

Priority fees work based on what the compute budget limit is, not how much you actually use. The transaction whose link you posted didn't set the Compute budget limit, so it gets set to the default, ...
McBain's user avatar
  • 5,384
2 votes
Accepted

Where are fees charged in the execution process?

Consuming CUs is done through the InvokeContext, which implements the ContextObject trait at https://github.com/anza-xyz/agave/blob/6e067fcd28620a32eab8461ad5e5be79e28d41f7/program-runtime/src/...
Jon C's user avatar
  • 19.6k
2 votes
Accepted

How do I add priority fees to a transaction using the release candidate web3.js version?

All of the program clients are now autogenerated (using Codama) and are available in the @solana-program namespace. You'll want to use @solana-program/compute-budget and @solana-program/system. import ...
steveluscher's user avatar
  • 3,153
1 vote

How are Solana fees used to prioritise transactions?

Prioritization isn't enforced by the protocol, but typically nodes will prefer to prioritize based on the compute unit price. For example, if my transaction has a compute unit price of 1_000_000, and ...
Jon C's user avatar
  • 19.6k
1 vote

Solana Compute Unit and and Compute Limit Question, weird values in the default config of the Dapp im trying to set up

The unit price is set in micro lamports and 1 lamport = 1e6 micro lamports. I assume the example value in your env file might be in micro lamport which it will be 0.002 SOL in total. If you're using ...
dev4all.sol's user avatar
1 vote

Where can I find how many CUs different operations and syscalls cost?

Check out this, by Jonas, https://github.com/solana-developers/cu_optimizations?tab=readme-ov-file#how-to-measure-cu The best way to measure CU is to use the solana program log. /// Total extra ...
Jimii's user avatar
  • 7,712
1 vote
Accepted

Are transaction compute costs static or variable?

Consider an instruction like this : pub fn my_instruction( ctx: Context<MyInstruction>, my_param: u64, ) -> Result<()> { let mut res = 0; if my_param == 1 { for ...
McBain's user avatar
  • 5,384
1 vote

Compute Budget Program Behavior: Direct Call vs. CPI Call and Missing Fees Issue

The Compute Budget program does not work when invoked via CPI, and must be called at the top-level of a transaction. The runtime scans through all instructions in a transaction prior to execution, ...
Jon C's user avatar
  • 19.6k
1 vote

How do priority fees (from the ComputeBudget program) prioritize transactions?

Increasing your transaction fee boosts its priority, but it competes only within the same slot, not guaranteeing inclusion with others. For NFT sniping, higher fees may help, but they don't ensure the ...
Ellie's user avatar
  • 122

Only top scored, non community-wiki answers of a minimum length are eligible