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.
Parameters
<xdr.TransactionEnvelope>
- The transaction to be simulated (serialized in base64)
Returns
<object>
minResourceFee
:<string>
- Stringified-number of the recommended minimum resource fee to add when submitting the transaction. This fee is to be added on top of the Stellar network fee.cost
:<object>
- Information about instructions used, etc.cpuInsns
:<string>
- Stringified-number of the total cpu instructions consumed by this transactionmemBytes
:<string>
- Stringified-number of the total memory bytes allocated by this transaction
results
:<object[]>
- Iferror
is present then results will not be in the response. There will be one result object for each Host Function invocation, in the same order the Host Function was supplied.xdr
:<xdr.ScVal>
- (optional) Only present on success. xdr-encoded return value of the Host Function call.auth
:<xdr.ContractAuth[]>
- Per-address authorizations recorded when simulating this Host Function call. (an array of serialized base64 strings)
transactionData
:<xdr.SorobanTransactionData>
- 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).events
:<xdr.DiagnosticEvent[]>
- Array of the events emitted during the contract invocation(s). The events are ordered by their emission time. (an array of serialized base64 strings)latestLedger
:<string>
- Stringified-number of the current latest ledger observed by the node when this response was generated.error
:<string>
- (optional) only present if the transaction failed. This field will include more details fromstellar-core
about why the invoke host function call failed.
Examples
Request
{
"jsonrpc": "2.0",
"id": 1102,
"method": "simulateTransaction",
"params": {
"transaction": "AAAAAgAAAABzdv3ojkzWHMD7KUoXhrPx0GH18vHKV0ZfqpMiEblG1gAAAGQAAAAAAAAABAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAHN2/eiOTNYcwPspSheGs/HQYfXy8cpXRl+qkyIRuUbWAAAAGAAAAAIAAAAAAAAABAAAAA0AAAAg4avr0cYyEk0etiaStUgJ889XGSqUqZEZcCyR+ma87LIAAAAPAAAABGF1dGgAAAATAAAAAAAAAABi/B0L0JGythwN1lY0aypo19NHxvLCyO5tBEcCVvwF9wAAAA8AAAAFd29ybGQAAAAAAAAAAAAAAAAAAAQAAAANAAAAIOGr69HGMhJNHrYmkrVICfPPVxkqlKmRGXAskfpmvOyyAAAADwAAAARhdXRoAAAAEwAAAAAAAAAAYvwdC9CRsrYcDdZWNGsqaNfTR8bywsjubQRHAlb8BfcAAAAPAAAABXdvcmxkAAAAAAAAAAAAAAAAAAAA"
}
}
Response
{
"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="
},
{
"auth": [
"AAAAAQAAAAAAAAAAYvwdC9CRsrYcDdZWNGsqaNfTR8bywsjubQRHAlb8BfcAAAAAAAAAAeGr69HGMhJNHrYmkrVICfPPVxkqlKmRGXAskfpmvOyyAAAABGF1dGgAAAACAAAAEwAAAAAAAAAAYvwdC9CRsrYcDdZWNGsqaNfTR8bywsjubQRHAlb8BfcAAAAPAAAABXdvcmxkAAAAAAAAAAAAAAA="
],
"xdr": "AAAAEwAAAAAAAAAAYvwdC9CRsrYcDdZWNGsqaNfTR8bywsjubQRHAlb8Bfc="
}
],
"cost": {
"cpuInsns": "2222468",
"memBytes": "2204681"
},
"latestLedger": "23456"
}
}