simulateTransaction
Simulate sending a transaction. This method uses 160 credits from your daily balance.
This method is useful for testing and debugging transactions before sending them to the network.
Parameters
- transaction: (string) [required] - The transaction as an encoded string. The transaction must have a valid block hash, but doesn't need to be signed.
- config: (object) [optional] - Configuration object with the following options:- commitment: (string) [optional] - The commitment level to use for the query. The default is- finalized. Possible values are:- finalized- Queries the most recent block confirmed by a super majority of the cluster as having reached maximum lockout, meaning the cluster has recognized this block as finalized.
- confirmed- Queries the most recent block that has been voted on by a super majority of the cluster.
- processed- Queries its most recent block. The block may still be skipped by the cluster.
 
- sigVerify: (boolean) [optional] - If- true, verifies the signatures in the transaction. Conflicts with- replaceRecentBlockhash. The default is- false.
- replaceRecentBlockhash: (boolean) [optional] - If- true, replaces the recent block hash in the transaction with the latest block hash. Conflicts with- sigVerify. The default is- false.
- encoding: (string) [optional] - The encoding format to use. Can be one of- base58(deprecated) or- base64.
- minContextSlot: [optional] - The minimum slot to use for the query.
- innerInstructions: (boolean) [optional] - If- true, returns the inner instructions of the transaction. The inner instructions will be- jsonParsedwhere possible, otherwise- json.
- accounts: (object) [optional] - An object containing the following fields:- addresses: (array) [optional] - An array of addresses to include in the response.
- encoding: (string) [optional] - The encoding format to use. Can be one of- base58,- base64,- base64+zstd, or- jsonParsed.
 
 
Returns
result - null if the account doesn't exist; otherwise an object with the following fields:
- context- An object containing the following keys:- slot- The slot number of the block that was queried.
- apiVersion- The API version used for the query.
 
- value- An object with the following fields:- err- An error if transaction failed,- nullif transaction succeeded.
- logs- An array of log messages generated by the transaction. Returns- nullif the simulation failed.
- accounts-- data- The account data, encoded in the specified format.
- executable- A boolean indicating whether the account is executable.
- lamports- The number of lamports in the account.
- owner- The public key of the program that owns the account.
- rentEpoch- The epoch in which the account will next be due for rent.
- space- The size of the account data in bytes.
 
- unitsConsumed- The number of compute units consumed by the transaction.
- returnData- An array of objects containing the following fields:- programId- The public key of the program that executed the transaction.
- data- The account data, encoded as- base64binary data.
 
- innerInstructions- An array of inner instructions.
 
Request
- curl
curl https://solana-testnet.infura.io/v3/<YOUR-API-KEY> \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "id": 1, "method": "simulateTransaction", "params": ["AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEDArczbMia1tLmq7zz4DinMNN0pJ1JtLdqIJPUw3YrGCzYAMHBsgN27lcgB6H2WQvFgyZuJYHa46puOQo9yQ8CVQbd9uHXZaGT2cvhRs7reawctIXtX1s3kTqM9YV+/wCp20C7Wj2aiuk5TReAXo+VTVg8QTHjs0UjNMMKCvpzZ+ABAgEBARU=", {"encoding": "base64"}]}'
Response
- JSON
{
  "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
}