simulateTransaction

Simulate sending a transaction.

📘

Supported on Solana (mainnet) only.

Parameters

  • <string> - Transaction, as an encoded string. The transaction must have a valid blockhash, but is not required to be signed.
  • (optional) <object> - Configuration object containing the following fields:
    • sigVerify: <bool> - if true the transaction signatures will be verified (default: false, conflicts with replaceRecentBlockhash)
    • (optional) commitment: <string> - Commitment level to simulate the transaction at (default: "finalized").
    • (optional) encoding: <string> - Encoding used for the transaction data. Either "base58" (slow, DEPRECATED), or "base64". (default: "base58").
    • (optional) replaceRecentBlockhash: <bool> - if true the transaction recent blockhash will be replaced with the most recent blockhash. (default: false, conflicts with sigVerify)
    • (optional) accounts: <object> - Accounts configuration object containing the following fields:
      • (optional) encoding: <string> - encoding for returned Account data, either "base64" (default), "base64+zstd" or "jsonParsed". "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 binary encoding, detectable when the data field is type <string>.
      • addresses: <array> - An array of accounts to return, as base-58 encoded strings
    • (optional) minContextSlot: <number> - set the minimum slot that the request can be evaluated at.

Returns

An RpcResponse containing a TransactionStatus object 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

API Endpoint

The format of an Solana API endpoint is
https://open-platform.nodereal.io/{{apiKey}}/solana/

Here is an example:
https://open-platform.nodereal.io/4c0a1c23661a4e26bcbcwed461e34ea9/solana/

Example

Request

curl https://open-platform.nodereal.io/{{apiKey}}/solana/ \
  -X POST \
  -H "Content-Type: application/json" \
  --data '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "simulateTransaction",
    "params": [
      "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEDArczbMia1tLmq7zz4DinMNN0pJ1JtLdqIJPUw3YrGCzYAMHBsgN27lcgB6H2WQvFgyZuJYHa46puOQo9yQ8CVQbd9uHXZaGT2cvhRs7reawctIXtX1s3kTqM9YV+/wCp20C7Wj2aiuk5TReAXo+VTVg8QTHjs0UjNMMKCvpzZ+ABAgEBARU=",
      {
        "encoding":"base64",
      }
    ]
  }
'

Result

{
  "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
}