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

# Simulate Transaction

> Simulate a Soroban transaction for resource estimates.

Interacts with the Soroban RPC to simulate the execution of a transaction. This is required for smart contract calls to determine resource fees and footprints.

### Request Body

<ParamField body="transaction" type="string" required>
  The base64-encoded XDR of the transaction to simulate.
</ParamField>

### Response Fields

<ResponseField name="resourceFee" type="string">
  The estimated Soroban resource fee in stroops.
</ResponseField>

<ResponseField name="latestLedger" type="number">
  The ledger number used for the simulation.
</ResponseField>

<ResponseField name="transactionData" type="string">
  The base64-encoded `SorobanTransactionData` containing the required footprints.
</ResponseField>

<ResponseField name="events" type="array">
  A list of diagnostic events emitted during the simulation.
</ResponseField>

### Error Codes

| Code                | Description                                          |
| :------------------ | :--------------------------------------------------- |
| `VALIDATION_ERROR`  | The provided XDR is not a valid Soroban transaction. |
| `SIMULATION_FAILED` | The smart contract execution failed or panicked.     |

### SDK Example

```typescript theme={null}
import { Grat } from '@grat-official-sdk/sdk';
const grat = Grat.testnet();

const simulation = await grat.simulate(sorobanTx);
console.log(simulation.resourceFee);
```

[View on GitHub](https://github.com/gratnetwork/grat)
