I am using solana web3js to interact with a program and send tx. In some of the transactions, it fails due to Compute Units limit. I can increase the Compute Unit to a very high fixed number and make them all pass, but it looks very inefficient for using chain resources.

How can I calculate the exact budget for each tx using solana web3js or any other tool?

1 Answer 1


You can simulate the transaction and then use the result to set the compute budget.

Here is an example of how to do that. I dont have a written form of it yet, but there should be a guide soon.

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.