> ## Documentation Index
> Fetch the complete documentation index at: https://protochain.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# SimulateTransaction

> Dry-run a transaction against current ledger state without committing it.

Simulates transaction execution against the current ledger state without committing anything on-chain. Returns success/failure, program logs, and any error details.

<Note>
  Simulation success does not guarantee on-chain success. If ledger state changes between simulation and submission (for example, another transaction modifies an account), the transaction may still fail.
</Note>

## Request

<ResponseField name="transaction" type="Transaction (object)" required>
  A compiled transaction (COMPILED state or later).
</ResponseField>

<ResponseField name="commitment_level" type="CommitmentLevel (enum)">
  Optional. Ledger state to simulate against. Defaults to CONFIRMED.
</ResponseField>

<Info>
  **commitment\_level** is optional. When omitted or set to `COMMITMENT_LEVEL_UNSPECIFIED`, the service defaults to `COMMITMENT_LEVEL_CONFIRMED`. See [CommitmentLevel](/api-reference/shared-types#commitmentlevel) for trade-offs between processed, confirmed, and finalized.
</Info>

## Response

<ResponseField name="success" type="bool">
  True if the simulation completed without errors.
</ResponseField>

<ResponseField name="error" type="string">
  Error message if the simulation failed. Empty when `success` is true.
</ResponseField>

<ResponseField name="logs" type="string[]">
  Program execution log lines from the simulation run. Useful for debugging instruction failures.
</ResponseField>

## Code Examples

<CodeGroup>
  ```go Go theme={null}
  resp, err := client.SimulateTransaction(ctx, &transaction_v1.SimulateTransactionRequest{
      Transaction: compiledTxn,
  })
  if err != nil {
      log.Fatal(err)
  }
  if !resp.Success {
      fmt.Printf("Simulation failed: %s\n", resp.Error)
      for _, log := range resp.Logs {
          fmt.Println(log)
      }
  }
  ```

  ```rust Rust theme={null}
  let response = client.simulate_transaction(tonic::Request::new(SimulateTransactionRequest {
      transaction: Some(compiled_txn),
      ..Default::default()
  })).await?;
  let sim = response.into_inner();
  if !sim.success {
      println!("Simulation failed: {}", sim.error);
      for log in &sim.logs {
          println!("{}", log);
      }
  }
  ```

  ```typescript TypeScript theme={null}
  const req = new SimulateTransactionRequest();
  req.setTransaction(compiledTxn);
  client.simulateTransaction(req, (err, response) => {
    if (!response.getSuccess()) {
      console.error("Simulation failed:", response.getError());
      response.getLogsList().forEach(log => console.log(log));
    }
  });
  ```
</CodeGroup>
