simulateTransaction
https://triport.io/rpc/stellarSubmits a trial contract invocation transaction through Stellar Soroban JSON-RPC.
Evaluates a base64-encoded transaction envelope without submitting it and can calculate transaction data, authorizations, resource fees, events, state changes, and restore data.
Use it before a Soroban invocation or for a read-only contract call. The result is advisory input to a separate submission workflow.
sendTransaction is unavailable on this API. Optional result fields may be absent, and result.error is an execution outcome rather than a transport error.
Parameters
JSON-RPC params is a by-name object. Only the fields below are defined by the OpenRPC catalog.
transactionstringrequiredinvokeHostFunction.resourceConfigobjectoptionalxdrFormatstringoptionalauthModestringoptionalParameter sub-fieldsobjectresourceConfig.instructionLeewaynumberResponse
The response is copied unchanged from the accepted fixture.
resultobjectresult.errorstringresult.eventsarray of stringInvokeHostFunction operations, note that it can be present on error, providing extra context about what failed.result.latestLedgernumberresult.minResourceFeestringresult.restorePreambleobjectInvokeHostFunction operations. If present, it indicates that the simulation detected archived 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.result.restorePreamble.minResourceFeestringRestoreFootprint operation. This fee is to be added on top of the Stellar network fee.result.restorePreamble.transactionDatastringRestoreFootprint operation.result.resultsarray of objectInvokeHostFunction operations.result.results[].autharray of stringresult.results[].xdrstringresult.stateChangesarray of objectInvokeHostFunction operations, this field will be an array of LedgerEntrys before and after simulation occurred. Note that at least one of before or after will be present: before and no after indicates a deletion event, the inverse is a creation event, and both present indicates an update event. Or just check the type.result.stateChanges[].afterstring or nullLedgerEntry state after simulationresult.stateChanges[].beforestring or nullLedgerEntry state prior to simulationresult.stateChanges[].keystringLedgerKey for this deltaresult.stateChanges[].typestringresult.transactionDatastringErrors
Errors use the standard JSON-RPC envelope. See Stellar errors and the shared error reference.
| Code | Meaning | When it happens |
|---|---|---|
-32602 | Invalid params | the by-name object or a field has the wrong type; positional-array style params are rejected. |
-32601 | Method not found | The method is absent from the published Stellar OpenRPC catalog. |
401 | Unauthorized | The API key is missing or invalid. |
429 | Rate limited | The stellar_read_rpc RPS budget is exceeded. |
Examples
JavaScript (fetch)
const request = {
"jsonrpc": "2.0",
"id": 1,
"method": "simulateTransaction",
"params": {
"transaction": "${stellar.transaction_xdr}"
}
};
const response = await fetch("https://triport.io/rpc/stellar", {
method: "POST",
headers: {
"x-token": process.env.TRIPORT_API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify(request),
});
const payload = await response.json();
if (!response.ok || payload.error) throw new Error(JSON.stringify(payload.error));
console.log(payload.result);Notes
- Simulation does not guarantee a later submission result.
- Fee-like values are string encoded.
- Related:
getLedgerEntriesandgetEvents; transaction submission is unavailable. - This is a read-only surface. No write or transaction-submission method is published.