> For the complete documentation index, see [llms.txt](/llms.txt).

# `simulateTransaction`

Submits a trial transaction and returns the data required to build, sign, and submit it. This method uses [160 credits](/get-started/pricing/) from your daily balance.

The transaction must contain exactly one operation, of type `invokeHostFunction`, `extendFootprintTtl`, or `restoreFootprint`. `extendFootprintTtl` and `restoreFootprint` require Soroban transaction data on the envelope. The transaction must not contain a memo. You can also use this method to call a read-only contract function.

## Parameters[​](#parameters "Direct link to Parameters")

- `transaction`: (string) _[required]_ - Transaction envelope, as a base64-encoded string.
- `resourceConfig`: (object) _[optional]_ - Resource budgeting options:  
  - `instructionLeeway`: (integer) _[optional]_ - Extra instructions to allow when budgeting resources.
- `xdrFormat`: (string) _[optional]_ - Format for XDR fields in the response. `base64` is the default. `json` returns unpacked JSON. Do not rely on a stable schema for the JSON form, because it changes when the underlying XDR changes.
- `authMode`: (string) _[optional]_ - Authorization mode for an `invokeHostFunction` operation. If omitted, the node uses `enforce` when the operation already contains authorization entries, and `record` when it does not. `record` and `record_allow_nonroot` are rejected when the operation already contains authorization entries. This field is rejected for `extendFootprintTtl` and `restoreFootprint`. One of:  
  - `enforce` - Enforce authorization checks.
  - `record` - Record authorization without enforcing it.
  - `record_allow_nonroot` - Record authorization and allow non-root invocations.

## Returns[​](#returns "Direct link to Returns")

`result`: (object) - Simulation outcome. XDR fields are base64-encoded strings unless `xdrFormat` is `json`.

- `latestLedger`: (integer) - Sequence number of the latest ledger known to the node when it handled the request.
- `minResourceFee`: (string) _[optional]_ - Recommended minimum resource fee, as a string. Add this fee on top of the network fee. Omitted when simulation fails.
- `results`: (array) _[optional]_ - Host-function result. Present when an `invokeHostFunction` simulation succeeds. The array contains one object:  
  - `xdr`: (string) - Return value of the host function.
  - `auth`: (array) - Authorizations recorded for the call.
- `transactionData`: (string) _[optional]_ - Recommended Soroban transaction data, including the resource fee and ledger footprint. Omitted when simulation fails.
- `events`: (array) _[optional]_ - Events emitted during the invocation, in emission order. Present for `invokeHostFunction` simulations, including some failures.
- `restorePreamble`: (object) _[optional]_ - Present when archived ledger entries must be restored before submission.  
  - `minResourceFee`: (string) - Recommended minimum resource fee for the `RestoreFootprint` operation.
  - `transactionData`: (string) - Recommended Soroban transaction data for that operation.
- `stateChanges`: (array) _[optional]_ - Ledger entries changed by a successful `invokeHostFunction` simulation. Each change contains:  
  - `type`: (string) - `created`, `updated`, or `deleted`.
  - `key`: (string) - `LedgerKey` for the change.
  - `before`: (string) - `LedgerEntry` before simulation. `null` when the entry was created.
  - `after`: (string) - `LedgerEntry` after simulation. `null` when the entry was deleted.
- `error`: (string) _[optional]_ - Why the simulation failed. Present only on failure.

### Request[​](#request "Direct link to Request")

- curl

```
curl https://stellar-mainnet.infura.io/v3/<YOUR-API-KEY> \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "id": 1, "method": "simulateTransaction", "params": {"transaction": "AAAAAgAAAAA7mRE4Dv6Yi6CokA6xz+RPNm99vpRr7QdyQPf2JN8VxQAAAGQAAAAAAAAAZQAAAAEAAAAAAAAAAAAAAABp/P05AAAAAAAAAAEAAAAAAAAAGAAAAAAAAAABJbT82FmuwvpjSEOMSJs8PBDJi20hvk/TyzDLaJU++XcAAAAEbmFtZQAAAAAAAAAAAAAAAAAAAAA="}}'

```

### Response[​](#response "Direct link to Response")

- JSON

```
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "transactionData": "AAAAAAAAAAEAAAAGAAAAASW0/NhZrsL6Y0hDjEibPDwQyYttIb5P08swy2iVPvl3AAAAFAAAAAEAAAAAAAHGHQAAAAAAAAAAAAAAAAAAMAo=",
    "events": [
      "AAAAAQAAAAAAAAAAAAAAAgAAAAAAAAADAAAADwAAAAdmbl9jYWxsAAAAAA0AAAAgJbT82FmuwvpjSEOMSJs8PBDJi20hvk/TyzDLaJU++XcAAAAPAAAABG5hbWUAAAAB",
      "AAAAAQAAAAAAAAABJbT82FmuwvpjSEOMSJs8PBDJi20hvk/TyzDLaJU++XcAAAACAAAAAAAAAAIAAAAPAAAACWZuX3JldHVybgAAAAAAAA8AAAAEbmFtZQAAAA4AAAAGbmF0aXZlAAA="
    ],
    "minResourceFee": "12298",
    "results": [
      {
        "auth": [],
        "xdr": "AAAADgAAAAZuYXRpdmUAAA=="
      }
    ],
    "latestLedger": 64923230
  }
}

```
