Skip to main content

simulateTransaction

Simulate sending a transaction

Parameters

Transaction <string>

  • Fully-signed Transaction, as encoded string.

Configuration <object>

  • Configuration object containing the following optional fields:

    • encoding: <string> - encoding format for the transaction data

      ["base58", "base64"]
    • sigVerify: <bool> - if true the transaction signatures will be verified (conflicts with replaceRecentBlockhash)

    • replaceRecentBlockhash: <bool> - if true the transaction recent blockhash will be replaced with the most recent blockhash. (conflicts with sigVerify)

    • innerInstructions: <bool> - If true the response will include inner instructions. These inner instructions will be jsonParsed where possible, otherwise json.

    • accounts: <object> - Accounts configuration object containing the following fields:

      • addresses: <array> - An array of accounts to return, as base-58 encoded strings

      • encoding: <string> - encoding for returned Account data

        ["base64", "base58", "base64+zstd", "jsonParsed"]
        Details
        • 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)
  • 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://testnet.atlas.xyz/?apikey=$ATLAS_API_KEY" -X POST -H "Content-Type: application/json" -d '
{
"jsonrpc": "2.0",
"id": "0bdba4c1-3073-41b0-b849-46f14e004e38",
"method": "simulateTransaction",
"params": [
"AQe5nqUXhDz1R8JDqPqROQxkwp50mdiUlZDmSrxG/RIdd98WdvCQAla5kAKGALz77LSpo9kwJ8gJw1sf+LRmGA0BAAEDdPm+Cnw7F9dNknpXES+CbZfw0iT7frqEeCP8IhQo0cy/Xl+YMnLu2r+o+iFDSgJzhmKlz0YYl50EObvGqXrFLwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAbzpM6zyDv284aWUppiipjTEJLNerWZMYRVYbYg9PXh0BAgIAAQwCAAAAQEIPAAAAAAA=",
{
"encoding":"base64",
"replaceRecentBlockhash": true
}
]
}
'

Response

{
"jsonrpc": "2.0",
"id": "0bdba4c1-3073-41b0-b849-46f14e004e38",
"result": {
"context": {
"slot": 12461367
},
"value": {
"err": null,
"logs": [
"Program 11111111111111111111111111111111 invoke [1]",
"Program 11111111111111111111111111111111 success"
],
"accounts": [
{
"lamports": 998995000,
"data": ["", "base64"],
"owner": "11111111111111111111111111111111",
"executable": false,
"rentEpoch": 0,
"space": 0
},
{
"lamports": 1000000,
"data": ["", "base64"],
"owner": "11111111111111111111111111111111",
"executable": false,
"rentEpoch": 0,
"space": 0
},
{
"lamports": 1037040,
"data": ["c29sYW5hX3N5c3RlbV9wcm9ncmFt", "base64"],
"owner": "NativeLoader1111111111111111111111111111111",
"executable": true,
"rentEpoch": 0,
"space": 21
}
],
"unitsConsumed": 0,
"returnData": null,
"innerInstructions": null,
"replacementBlockhash": {
"blockhash": "J11xkq6LYPNqYfSHteBpLti2Rtg3pMqMCsjRRN7P7YDN",
"lastValidBlockHeight": 12461878
}
}
}
}