simulateTransaction

Submit a trial contract invocation to simulate how it would be executed by the network. This endpoint calculates the effective transaction data, required authorizations, and minimal resource fee. It provides a way to test and analyze the potential outcomes of a transaction without actually submitting it to the network.

This method will use 10 Compute Units.


Reference: Here

Parameters

  • transaction (string)(required) The transaction to be simulated (serialized in base64)

Returns

  • minResourceFee string (optional) - Stringified number - Recommended minimum resource fee to add when submitting the transaction. This fee is to be added on top of the Stellar network fee. Not present in case of error.

  • cost object (optional) - Information about instructions used, etc. Not present in case of error.

  • results array[object] (optional) - This array will only have one element: the result for the Host Function invocation. Only present on successful simulation (i.e. no error) of InvokeHostFunction operations.

  • transactionData string (optional) - Serialized base64 string - The recommended Soroban Transaction Data to use when submitting the simulated transaction. This data contains the refundable fee and resource usage information such as the ledger footprint and IO access data (serialized in a base64 string). Not present in case of error.

  • events array (optional) - Array of serialized base64 strings - Array of the events emitted during the contract invocation. The events are ordered by their emission time. (an array of serialized base64 strings). Only present when simulating of InvokeHostFunction operations, note that it can be present on error, providing extra context about what failed.

  • restorePreamble (object) (optional) - It can only be present on sucessful simulation (i.e. no error) of InvokeHostFunction operations. If present, it indicates that the simulation detected expired ledger entries which need to be restored before the submission of the InvokeHostFunction operation. The minResourceFee and transactionData fields should be used to submit a transaction containing a RestoreFootprint operation

  • latestLedger (string) - A Stringified number - Current latest closed ledger (LCL) observed by the node when this response was generated. Always present.

  • error string (optional) - This field will include details about why the invoke host function call failed. Only present if the transaction simulation failed.

// Result
{
  "jsonrpc": "2.0",
  "id": 1102,
  "result": {
    "transactionData": "AAAAAwAAAAAAAAAAYvwdC9CRsrYcDdZWNGsqaNfTR8bywsjubQRHAlb8BfcAAAAG4avr0cYyEk0etiaStUgJ889XGSqUqZEZcCyR+ma87LIAAAAUAAAAB8zDhJ3ZTMHmdBjlVh/7d1HDdo+QI1ZXGmeRzBwVAoVXAAAAAQAAAAbhq+vRxjISTR62JpK1SAnzz1cZKpSpkRlwLJH6ZrzssgAAABUAAAAAAAAAAGL8HQvQkbK2HA3WVjRrKmjX00fG8sLI7m0ERwJW/AX3ACb/vgAAFcQAAAC0AAABrAAAAAAAAABUAAAAAA==",
    "events": [
      "AAAAAQAAAAAAAAAB4avr0cYyEk0etiaStUgJ889XGSqUqZEZcCyR+ma87LIAAAABAAAAAAAAAAEAAAAOAAAABGF1dGgAAAAPAAAABXdvcmxkAAAA",
      "AAAAAQAAAAAAAAAB4avr0cYyEk0etiaStUgJ889XGSqUqZEZcCyR+ma87LIAAAABAAAAAAAAAAEAAAAOAAAABGF1dGgAAAAPAAAABXdvcmxkAAAA"
    ],
    "minResourceFee": "79488",
    "results": [
      {
        "auth": [
          "AAAAAQAAAAAAAAAAYvwdC9CRsrYcDdZWNGsqaNfTR8bywsjubQRHAlb8BfcAAAAAAAAAAOGr69HGMhJNHrYmkrVICfPPVxkqlKmRGXAskfpmvOyyAAAABGF1dGgAAAACAAAAEwAAAAAAAAAAYvwdC9CRsrYcDdZWNGsqaNfTR8bywsjubQRHAlb8BfcAAAAPAAAABXdvcmxkAAAAAAAAAAAAAAA="
        ],
        "xdr": "AAAAEwAAAAAAAAAAYvwdC9CRsrYcDdZWNGsqaNfTR8bywsjubQRHAlb8Bfc="
      }
    ],
    "cost": {
      "cpuInsns": "2222468",
      "memBytes": "2204681"
    },
    "latestLedger": "23456"
  }
}
curl https://mainnet.stellar.validationcloud.io/v1/<YOUR_API_KEY_HERE> \
    -X POST \
    -H "Content-Type: application/json" \
    -d '{
  "jsonrpc": "2.0",
  "id": 8675309,
  "method": "simulateTransaction",
  "params": {
    "transaction": "AAAAAgAAAABzdv3ojkzWHMD7KUoXhrPx0GH18vHKV0ZfqpMiEblG1gAAAGQAAAAAAAAABAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAHN2/eiOTNYcwPspSheGs/HQYfXy8cpXRl+qkyIRuUbWAAAAGAAAAAIAAAAAAAAABAAAAA0AAAAg4avr0cYyEk0etiaStUgJ889XGSqUqZEZcCyR+ma87LIAAAAPAAAABGF1dGgAAAATAAAAAAAAAABi/B0L0JGythwN1lY0aypo19NHxvLCyO5tBEcCVvwF9wAAAA8AAAAFd29ybGQAAAAAAAAAAAAAAAAAAAQAAAANAAAAIOGr69HGMhJNHrYmkrVICfPPVxkqlKmRGXAskfpmvOyyAAAADwAAAARhdXRoAAAAEwAAAAAAAAAAYvwdC9CRsrYcDdZWNGsqaNfTR8bywsjubQRHAlb8BfcAAAAPAAAABXdvcmxkAAAAAAAAAAAAAAAAAAAA"
  }
}'

Last updated