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.base64is the default.jsonreturns 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 aninvokeHostFunctionoperation. If omitted, the node usesenforcewhen the operation already contains authorization entries, andrecordwhen it does not.recordandrecord_allow_nonrootare rejected when the operation already contains authorization entries. This field is rejected forextendFootprintTtlandrestoreFootprint. 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 aninvokeHostFunctionsimulation 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 forinvokeHostFunctionsimulations, including some failures.restorePreamble: (object) [optional] - Present when archived ledger entries must be restored before submission.minResourceFee: (string) - Recommended minimum resource fee for theRestoreFootprintoperation.transactionData: (string) - Recommended Soroban transaction data for that operation.
stateChanges: (array) [optional] - Ledger entries changed by a successfulinvokeHostFunctionsimulation. Each change contains:type: (string) -created,updated, ordeleted.key: (string) -LedgerKeyfor the change.before: (string) -LedgerEntrybefore simulation.nullwhen the entry was created.after: (string) -LedgerEntryafter simulation.nullwhen the entry was deleted.
error: (string) [optional] - Why the simulation failed. Present only on failure.
Request
- curl
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
- JSON
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"transactionData": "AAAAAAAAAAEAAAAGAAAAASW0/NhZrsL6Y0hDjEibPDwQyYttIb5P08swy2iVPvl3AAAAFAAAAAEAAAAAAAHGHQAAAAAAAAAAAAAAAAAAMAo=",
"events": [
"AAAAAQAAAAAAAAAAAAAAAgAAAAAAAAADAAAADwAAAAdmbl9jYWxsAAAAAA0AAAAgJbT82FmuwvpjSEOMSJs8PBDJi20hvk/TyzDLaJU++XcAAAAPAAAABG5hbWUAAAAB",
"AAAAAQAAAAAAAAABJbT82FmuwvpjSEOMSJs8PBDJi20hvk/TyzDLaJU++XcAAAACAAAAAAAAAAIAAAAPAAAACWZuX3JldHVybgAAAAAAAA8AAAAEbmFtZQAAAA4AAAAGbmF0aXZlAAA="
],
"minResourceFee": "12298",
"results": [
{
"auth": [],
"xdr": "AAAADgAAAAZuYXRpdmUAAA=="
}
],
"latestLedger": 64923230
}
}