# Simulate Transaction

<figure><img src="https://1878311582-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrN5WLmmo14XNSVjsb16D%2Fuploads%2F7Xj5jaUGrMi5SOqnaBT5%2Fimage.png?alt=media&#x26;token=ef903587-a7d9-48c1-8675-442859216f0e" alt="" width="563"><figcaption></figcaption></figure>

Given a transaction object, the Simulate Transaction pipeline will communicate with the RPC server to simulate the transaction execution and receive the simulation parameters. The pipeline will throw an error in case any issues arise when communicating with the RPC server or in case the simulation wasn't successful.

It is important to note that in case any underlying state for this invocation is expired and a restore is required, the simulation will still come back as successful and move forward with the pipeline. In these cases, the output `response` will be of type `SorobanRpc.Api.SimulateTransactionRestoreResponse`.  An [AutoRestore](https://docs.cheesecakelabs.com/stellar-plus/reference/utils/plugins/auto-restore-plugin) plugin can be used to automatically perform the restore transaction before exiting the Simulate Transaction pipeline.

For further details on this scenario, refer to Soroban's official documentation on [State Archival](https://soroban.stellar.org/docs/soroban-internals/state-archival).

## Input

```typescript
type SimulateTransactionPipelineInput = {
  transaction: Transaction
  rpcHandler: RpcHandler
}
```

* **transaction**: Transaction to be simulated with the RPC server.
* **rpcHandler**: The RPC handler to be used when communicating with the RPC. Refer to the [rpc](https://docs.cheesecakelabs.com/stellar-plus/reference/rpc "mention")section for further details.

## Output

```typescript
type SimulateTransactionPipelineOutput = {
  response: SorobanRpc.Api.SimulateTransactionSuccessResponse | SorobanRpc.Api.SimulateTransactionRestoreResponse
  output?: SimulatedInvocationOutput & ResourcesOutput
  assembledTransaction: Transaction
}
```

* **response**: The successful simulation response from the RPC server. This response might be either of type `SorobanRpc.Api.SimulateTransactionSuccessResponse` or `SorobanRpc.Api.SimulateTransactionRestoreResponse` from[ js-stellar-sdk](https://github.com/stellar/js-stellar-sdk).
* **output**: Optional output to be included by different plugins, attaching specific information to the pipeline output.&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cheesecakelabs.com/stellar-plus/reference/core/pipelines/simulate-transaction.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
