simulateTransaction | Solana

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.

👍

Get your own node endpoint today

Start for free and get your app to production levels immediately. No credit card required.

You can sign up with your GitHub, X, Google, or Microsoft account.

Parameters

  1. transaction (string) - A base64 encoded string representing the transaction to simulate.
  2. config (object, optional) - Configuration object containing the following optional fields:
    • encoding (string) - Encoding used for the transaction data. Default is "base64".

Response

The response includes a result object with details about the simulated transaction execution, including:

  • err - If the transaction simulation was successful, this field will be null. Otherwise, it will contain an error message.
  • logs - An array of log messages the transaction produced during simulation.
  • accounts - An array of account information after the simulation.
  • unitsConsumed - The number of compute units consumed by the transaction.

Use case

A common use case for simulateTransaction is to estimate the cost and effects of a transaction before actually sending it. This can help developers ensure their transactions will execute as expected and avoid unnecessary fees from failed transactions.

Try the simulateTransaction RPC method yourself

Language
Click Try It! to start a request and see the response here!