simulate Transaction
Simulates a transaction to preview its effects.
This is essential for Soroban transactions to:
Calculate resource requirements (CPU, memory, storage)
Determine authorization entries needed
Estimate resource fees
Preview contract invocation results
The transaction should contain exactly one operation of type:
InvokeHostFunctionOperation
ExtendFootprintTTLOperation
RestoreFootprintOperation
Any existing footprint in the transaction is ignored during simulation.
Example
val simulation = server.simulateTransaction(transaction)
if (simulation.error != null) {
println("Simulation failed: ${simulation.error}")
} else {
println("Min resource fee: ${simulation.minResourceFee}")
println("Results: ${simulation.results}")
}Return
Simulation results including costs, footprint, and results
Parameters
The transaction to simulate
Optional resource configuration for additional headroom
Optional authorization mode (ENFORCE, RECORD, RECORD_ALLOW_NONROOT)
When true (the default), requests Protocol-27 ADDRESS_V2 auth entries in recording modes. The flag is sent on every request; an explicit false requests legacy ADDRESS entries. RPC servers without Protocol 27 support ignore the flag and return legacy entries. Set false on networks below Protocol 27, where ADDRESS_V2 entries invalidate the transaction.
See also
Throws
If the RPC request fails