simulateTransaction
Submit a trial contract invocation to get back return values, expected ledger footprint, and expected costs.
Parameters
<xdr.TransactionEnvelope>
- The transaction to be simulated (serialized in base64)
Returns
<object>
cost
:<object>
- Information about the fees expected, 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
footprint
:<xdr.LedgerFootprint>
-Array of ledger keys expected to be written by this transaction. (serialized in base64)results
:<object[]>
- If error is present then results will not be in the responsexdr
:<xdr.ScVal>
- (optional) Only present on success. xdr-encoded return value of the contract call
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
The example transaction below invokes the increment
function from the increment
example contract.
Request
{
"jsonrpc": "2.0",
"id": 8675309,
"method": "simulateTransaction",
"params": {
"transaction": "AAAAAgAAAAAdq+kGxmBG/ikQNdYHQ2fBAG+8Av/xp1ZfPZ9Xt42ragAAJxAAAAAAAAAAAgAAAAEAAAAAAAAAAAAAAABjzuFcAAAAAAAAAAEAAAAAAAAAGAAAAAAAAAACAAAABAAAAAEAAAAGAAAAIBv6ziOnWcVRdGMZjtFKSWnLSndMp9JPVLLXxQqAvKqJAAAABQAAAAlpbmNyZW1lbnQAAAAAAAAAAAAAAAAAAAAAAAAA"
}
}
Response
{
"jsonrpc": "2.0",
"id": 8675309,
"result": {
"results": [
{
"xdr": "AAAAAQAAAAY="
}
],
"footprint": "AAAAAgAAAAYb+s4jp1nFUXRjGY7RSklpy0p3TKfST1Sy18UKgLyqiQAAAAMAAAADAAAAB9QqWUc9AUjduz5qrbJgYb/gACScB4Jq7yTT6x0QJfZfAAAAAQAAAAYb+s4jp1nFUXRjGY7RSklpy0p3TKfST1Sy18UKgLyqiQAAAAUAAAAHQ09VTlRFUgA=",
"cost": {
"cpuInsns": "163642",
"memBytes": "1506"
},
"latestLedger": "230473"
}
}