# Transaction Simulation and Compute Units

Solana’s execution model is deterministic and bound by compute limits. Before sending out a critical transaction (especially one involving multiple instructions or high complexity), it’s prudent to simulate it. Nyvo’s tooling leverages `simulateTransaction` as mentioned earlier. When you simulate, the Solana node executes the transaction against the current ledger state but without persisting changes, returning any logs and the number of **compute units** the transaction consumed. Compute units are a measure of execution time (roughly, 1 CU is a small fraction of microsecond of compute). Solana caps each transaction’s compute usage (default \~200k CU per instruction, up to 1.4M CU total with override).

**For Nyvo developers, this translates to:**

* If you have a very complex operation (maybe a governance vote counting hundreds of ballots, or an elaborate bonding curve calculation), you should simulate to see if it stays within the limit. Nyvo likely includes safeguards: e.g., if a single instruction approaches 200k CU, the program might split tasks or require multiple transactions. But ultimately, extremely compute-heavy logic might hit the ceiling.
* **Optimal Compute Budget:** Solana allows you to raise the limit via the compute budget program. Nyvo’s advanced mode might automatically insert a `SetComputeUnitLimit` instruction if it expects high usage. As a developer, you can also manually do this if needed. The recommended approach is: simulate to get used CUs, then request a limit slightly above that (with some margin). For instance, if simulation shows 210k CUs used, you might set the limit to 230k for safety. Nyvo’s API can handle this behind the scenes as described in the **Nyvo Internal API** section.
* **Fee Implications:** Normally, Solana fees are fixed per signature. However, if you set a custom compute limit and a **unit price** (priority fee), you pay `compute_unit_limit * compute_unit_price` in addition to base fee. By default, Nyvo likely sets the compute unit price to 0 (no extra fee) unless you explicitly want prioritization (e.g., your launch is time-sensitive in a congested network). Still, knowing the formula is important. For example, if you set a compute limit of 1,000,000 CU with a price of 1 micro-lamport per CU, the priority fee = 1,000,000 \* 1 = 1,000,000 micro-lamports = 1 lamport (very low). Higher prices give your tx a better chance to be processed first by validators, but for most Nyvo dApps this isn’t necessary except during extreme network congestion.

Nyvo provides feedback on transaction performance. In dev mode, after each transaction, it might log “Transaction consumed X out of Y requested compute units”. If you see it consistently hitting the limit, that’s a sign to increase it slightly. Also, be mindful that Solana’s compute usage can vary slightly between runs (e.g., if a PDA find function runs more iterations the next time, etc.). Always include a margin as best practice (Nyvo might default to +10% compute units as a buffer after simulation).



