For AI agents: a documentation index is available at /llms.txt. A markdown version of this page is available at the same URL with .md appended (or via Accept: text/markdown).
Skip to main content

simulateTransaction

Submits a trial transaction and returns the data required to build, sign, and submit it. This method uses 160 credits from your daily balance.

The transaction must contain exactly one operation, of type invokeHostFunction, extendFootprintTtl, or restoreFootprint. extendFootprintTtl and restoreFootprint require Soroban transaction data on the envelope. The transaction must not contain a memo. You can also use this method to call a read-only contract function.

Parameters​

  • transaction: (string) [required] - Transaction envelope, as a base64-encoded string.
  • resourceConfig: (object) [optional] - Resource budgeting options:
    • instructionLeeway: (integer) [optional] - Extra instructions to allow when budgeting resources.
  • xdrFormat: (string) [optional] - Format for XDR fields in the response. base64 is the default. json returns unpacked JSON. Do not rely on a stable schema for the JSON form, because it changes when the underlying XDR changes.
  • authMode: (string) [optional] - Authorization mode for an invokeHostFunction operation. If omitted, the node uses enforce when the operation already contains authorization entries, and record when it does not. record and record_allow_nonroot are rejected when the operation already contains authorization entries. This field is rejected for extendFootprintTtl and restoreFootprint. One of:
    • enforce - Enforce authorization checks.
    • record - Record authorization without enforcing it.
    • record_allow_nonroot - Record authorization and allow non-root invocations.

Returns​

result: (object) - Simulation outcome. XDR fields are base64-encoded strings unless xdrFormat is json.

  • latestLedger: (integer) - Sequence number of the latest ledger known to the node when it handled the request.
  • minResourceFee: (string) [optional] - Recommended minimum resource fee, as a string. Add this fee on top of the network fee. Omitted when simulation fails.
  • results: (array) [optional] - Host-function result. Present when an invokeHostFunction simulation succeeds. The array contains one object:
    • xdr: (string) - Return value of the host function.
    • auth: (array) - Authorizations recorded for the call.
  • transactionData: (string) [optional] - Recommended Soroban transaction data, including the resource fee and ledger footprint. Omitted when simulation fails.
  • events: (array) [optional] - Events emitted during the invocation, in emission order. Present for invokeHostFunction simulations, including some failures.
  • restorePreamble: (object) [optional] - Present when archived ledger entries must be restored before submission.
    • minResourceFee: (string) - Recommended minimum resource fee for the RestoreFootprint operation.
    • transactionData: (string) - Recommended Soroban transaction data for that operation.
  • stateChanges: (array) [optional] - Ledger entries changed by a successful invokeHostFunction simulation. Each change contains:
    • type: (string) - created, updated, or deleted.
    • key: (string) - LedgerKey for the change.
    • before: (string) - LedgerEntry before simulation. null when the entry was created.
    • after: (string) - LedgerEntry after simulation. null when the entry was deleted.
  • error: (string) [optional] - Why the simulation failed. Present only on failure.

Request​

curl https://stellar-mainnet.infura.io/v3/<YOUR-API-KEY> \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "id": 1, "method": "simulateTransaction", "params": {"transaction": "AAAAAgAAAAA7mRE4Dv6Yi6CokA6xz+RPNm99vpRr7QdyQPf2JN8VxQAAAGQAAAAAAAAAZQAAAAEAAAAAAAAAAAAAAABp/P05AAAAAAAAAAEAAAAAAAAAGAAAAAAAAAABJbT82FmuwvpjSEOMSJs8PBDJi20hvk/TyzDLaJU++XcAAAAEbmFtZQAAAAAAAAAAAAAAAAAAAAA="}}'

Response​

{
"jsonrpc": "2.0",
"id": 1,
"result": {
"transactionData": "AAAAAAAAAAEAAAAGAAAAASW0/NhZrsL6Y0hDjEibPDwQyYttIb5P08swy2iVPvl3AAAAFAAAAAEAAAAAAAHGHQAAAAAAAAAAAAAAAAAAMAo=",
"events": [
"AAAAAQAAAAAAAAAAAAAAAgAAAAAAAAADAAAADwAAAAdmbl9jYWxsAAAAAA0AAAAgJbT82FmuwvpjSEOMSJs8PBDJi20hvk/TyzDLaJU++XcAAAAPAAAABG5hbWUAAAAB",
"AAAAAQAAAAAAAAABJbT82FmuwvpjSEOMSJs8PBDJi20hvk/TyzDLaJU++XcAAAACAAAAAAAAAAIAAAAPAAAACWZuX3JldHVybgAAAAAAAA8AAAAEbmFtZQAAAA4AAAAGbmF0aXZlAAA="
],
"minResourceFee": "12298",
"results": [
{
"auth": [],
"xdr": "AAAADgAAAAZuYXRpdmUAAA=="
}
],
"latestLedger": 64923230
}
}