Skip to main content

Module simulation

Module simulation 

Source
Expand description

Transaction simulation for pre-flight validation.

This module provides utilities for simulating transactions before submission to predict outcomes, estimate gas costs, and catch errors early.

§Overview

Transaction simulation allows you to:

  • Predict success/failure before spending gas
  • Estimate gas costs more accurately than the gas estimator
  • Debug transactions by examining execution details
  • Validate payloads before committing to transactions

§Example

use aptos_sdk::transaction::simulation::SimulationResult;

let aptos = Aptos::testnet()?;

// Simulate a transaction
let result = aptos.simulate_payload(&account, payload).await?;

if result.success() {
    println!("Transaction will succeed!");
    println!("Estimated gas: {}", result.gas_used());
} else {
    println!("Transaction will fail: {}", result.vm_status());
}

Structs§

SimulatedEvent
An event from a simulated transaction.
SimulationOptions
Options for simulation.
SimulationResult
Result of a transaction simulation.
StateChange
A state change from a simulated transaction.
VmError
Detailed VM error information.

Enums§

VmErrorCategory
Categories of VM errors.