simulateTransaction RPC Method

Simulate sending a transaction

Parameters #

string required

Transaction, as an encoded string.

Info

The transaction must have a valid blockhash, but is not required to be signed.

object optional

Configuration object containing the following fields:

commitment string optional

Default: finalized

Commitment level to simulate the transaction at

sigVerify bool optional

if true the transaction signatures will be verified (conflicts with replaceRecentBlockhash)

replaceRecentBlockhash bool optional

if true the transaction recent blockhash will be replaced with the most recent blockhash. (conflicts with sigVerify)

minContextSlot number optional

the minimum slot that the request can be evaluated at

encoding string optional

Default: base58

Encoding used for the transaction data.

Values: base58 (slow, DEPRECATED), or base64.

innerInstructions bool optional

If true the response will include inner instructions. These inner instructions will be jsonParsed where possible, otherwise json.

accounts object optional

Accounts configuration object containing the following fields:

addresses array

An array of accounts to return, as base-58 encoded strings

encoding string

Default: base64

encoding for returned Account data

Values: base64base58base64+zstdjsonParsed

  • jsonParsed encoding attempts to use program-specific state parsers to return more human-readable and explicit account state data.
  • If jsonParsed is requested but a parser cannot be found, the field falls back to base64 encoding, detectable when the returned accounts.data field is type string.

Result #

The result will be an RpcResponse JSON object with value set to a JSON object with the following fields:

  • err: <object|string|null> - Error if transaction failed, null if transaction succeeded. TransactionError definitions
  • logs: <array|null> - Array of log messages the transaction instructions output during execution, null if simulation failed before the transaction was able to execute (for example due to an invalid blockhash or signature verification failure)
  • accounts: <array|null> - array of accounts with the same length as the accounts.addresses array in the request
    • <null> - if the account doesn't exist or if err is not null
    • <object> - otherwise, a JSON object containing:
      • lamports: <u64> - number of lamports assigned to this account, as a u64
      • owner: <string> - base-58 encoded Pubkey of the program this account has been assigned to
      • data: <[string, encoding]|object> - data associated with the account, either as encoded binary data or JSON format {<program>: <state>} - depending on encoding parameter
      • executable: <bool> - boolean indicating if the account contains a program (and is strictly read-only)
      • rentEpoch: <u64> - the epoch at which this account will next owe rent, as u64
  • unitsConsumed: <u64|undefined> - The number of compute budget units consumed during the processing of this transaction
  • returnData: <object|null> - the most-recent return data generated by an instruction in the transaction, with the following fields:
    • programId: <string> - the program that generated the return data, as base-58 encoded Pubkey
    • data: <[string, encoding]> - the return data itself, as base-64 encoded binary data
  • innerInstructions: <object | undefined> - Defined only if innerInstructions was set to true. The value is a list of inner instructions.

Code sample #

curl https://api.devnet.solana.com -s -X POST -H "Content-Type: application/json" -d '
  {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "simulateTransaction",
    "params": [
      "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEDArczbMia1tLmq7zz4DinMNN0pJ1JtLdqIJPUw3YrGCzYAMHBsgN27lcgB6H2WQvFgyZuJYHa46puOQo9yQ8CVQbd9uHXZaGT2cvhRs7reawctIXtX1s3kTqM9YV+/wCp20C7Wj2aiuk5TReAXo+VTVg8QTHjs0UjNMMKCvpzZ+ABAgEBARU=",
      {
        "encoding":"base64"
      }
    ]
  }
'

Response #

{
  "jsonrpc": "2.0",
  "result": {
    "context": {
      "slot": 218
    },
    "value": {
      "err": null,
      "accounts": null,
      "logs": [
        "Program 83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri invoke [1]",
        "Program 83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri consumed 2366 of 1400000 compute units",
        "Program return: 83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri KgAAAAAAAAA=",
        "Program 83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri success"
      ],
      "returnData": {
        "data": ["Kg==", "base64"],
        "programId": "83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri"
      },
      "unitsConsumed": 2366
    }
  },
  "id": 1
}