Skip to main content
Simulates transaction execution against the current ledger state without committing anything on-chain. Returns success/failure, program logs, and any error details.
Simulation success does not guarantee on-chain success. If ledger state changes between simulation and submission (for example, another transaction modifies an account), the transaction may still fail.

Request

transaction
Transaction (object)
required
A compiled transaction (COMPILED state or later).
commitment_level
CommitmentLevel (enum)
Optional. Ledger state to simulate against. Defaults to CONFIRMED.
commitment_level is optional. When omitted or set to COMMITMENT_LEVEL_UNSPECIFIED, the service defaults to COMMITMENT_LEVEL_CONFIRMED. See CommitmentLevel for trade-offs between processed, confirmed, and finalized.

Response

success
bool
True if the simulation completed without errors.
error
string
Error message if the simulation failed. Empty when success is true.
logs
string[]
Program execution log lines from the simulation run. Useful for debugging instruction failures.

Code Examples

resp, err := client.SimulateTransaction(ctx, &transaction_v1.SimulateTransactionRequest{
    Transaction: compiledTxn,
})
if err != nil {
    log.Fatal(err)
}
if !resp.Success {
    fmt.Printf("Simulation failed: %s\n", resp.Error)
    for _, log := range resp.Logs {
        fmt.Println(log)
    }
}