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

# simulateTransaction | Solana

> The Solana simulateTransaction method simulates sending a transaction. Reference for simulateTransaction on Solana via Chainstack.

The Solana `simulateTransaction` method simulates sending a transaction. This method does not send a transaction, but rather runs the transaction and returns the result of the execution.

This method is useful for predicting how a transaction will affect the state of the blockchain without actually committing any changes. It can be used to estimate transaction fees, check for potential errors, and understand the effects of a transaction before sending it.

## Parameters

1. `transaction` (string, required) — a base64 or base58 encoded string representing the transaction to simulate.
2. `config` (object, optional) — configuration object containing:
   * `encoding` (string) — encoding used for the transaction data. Values: `base58` (deprecated), `base64` (recommended). Default: `base58`.
   * `commitment` (string) — the bank state to simulate against. Default: `finalized`.
   * `sigVerify` (boolean) — when `true`, verify transaction signatures. Default: `false`. Conflicts with `replaceRecentBlockhash`.
   * `replaceRecentBlockhash` (boolean) — when `true`, replace the transaction's recent blockhash with the most recent blockhash from the bank. Default: `false`. Useful for simulating transactions with expired blockhashes. Conflicts with `sigVerify`.
   * `minContextSlot` (integer) — the minimum slot at which the request can be evaluated.
   * `innerInstructions` (boolean) — when `true`, include inner instructions in the response. Default: `false`.
   * `accounts` (object) — configuration for returning post-simulation account state:
     * `addresses` (array of strings) — array of account addresses to return.
     * `encoding` (string) — encoding for the returned account data. Values: `base64`, `base64+zstd`, `jsonParsed`.

## Response

The response includes a `result` object with:

* `err` — null if the simulation was successful, otherwise a transaction error object.
* `logs` (array of strings) — log messages the transaction produced during simulation.
* `unitsConsumed` (u64) — number of compute units consumed by the transaction.
* `accounts` — an array of account objects (or null) corresponding to the `accounts.addresses` request field.
* `returnData` — data returned by the last program that invoked `sol_set_return_data`. Contains `programId` (string) and `data` (`[base64_string, "base64"]` tuple).
* `innerInstructions` — array of inner instruction sets (when `innerInstructions: true` in the request). Each set contains `index` (the instruction index) and `instructions` (array of inner instruction objects).
* `fee` (u64, nullable) — the transaction fee in lamports.
* `preBalances` (array of u64) — account balances before the simulation.
* `postBalances` (array of u64) — account balances after the simulation.
* `preTokenBalances` — token balances before the simulation.
* `postTokenBalances` — token balances after the simulation.
* `loadedAddresses` — addresses loaded from address lookup tables. Contains `writable` (array of strings) and `readonly` (array of strings).
* `replacementBlockhash` — present when `replaceRecentBlockhash: true`. Contains `blockhash` (string) and `lastValidBlockHeight` (u64).

## Use case

A common use case for `simulateTransaction` is to estimate compute units, predict fee costs, and verify that a transaction will succeed before submitting it via [sendTransaction](/reference/solana-sendtransaction). This is especially useful for:

* Estimating the exact compute units needed to set via `ComputeBudgetProgram.setComputeUnitLimit`
* Debugging failed transactions by inspecting `logs` and `innerInstructions`
* Previewing token balance changes with `preTokenBalances` and `postTokenBalances`
* Checking post-execution account state via the `accounts` config


## OpenAPI

````yaml openapi/solana_node_api/simulateTransaction.json POST /9de47db917d4f69168e3fed02217d15b
openapi: 3.0.0
info:
  title: simulateTransaction example
  version: 1.0.0
  description: This is an API example for Solana's simulateTransaction.
servers:
  - url: https://nd-326-444-187.p2pify.com
security: []
paths:
  /9de47db917d4f69168e3fed02217d15b:
    post:
      tags:
        - query
      summary: simulateTransaction
      operationId: simulateTransaction
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                id:
                  type: integer
                  default: 1
                jsonrpc:
                  type: string
                  default: '2.0'
                method:
                  type: string
                  default: simulateTransaction
                params:
                  type: array
                  items:
                    anyOf:
                      - type: string
                        description: Transaction, as an encoded string
                      - type: object
                        properties:
                          encoding:
                            type: string
                            default: base64
                  default:
                    - >-
                      AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEDArczbMia1tLmq7zz4DinMNN0pJ1JtLdqIJPUw3YrGCzYAMHBsgN27lcgB6H2WQvFgyZuJYHa46puOQo9yQ8CVQbd9uHXZaGT2cvhRs7reawctIXtX1s3kTqM9YV+/wCp20C7Wj2aiuk5TReAXo+VTVg8QTHjs0UjNMMKCvpzZ+ABAgEBARU=
                    - encoding: base64
      responses:
        '200':
          description: Simulated transaction details
          content:
            application/json:
              schema:
                type: object
                properties:
                  jsonrpc:
                    type: string
                  id:
                    type: integer
                  result:
                    type: object

````