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§
- Simulated
Event - An event from a simulated transaction.
- Simulation
Options - Options for simulation.
- Simulation
Result - Result of a transaction simulation.
- State
Change - A state change from a simulated transaction.
- VmError
- Detailed VM error information.
Enums§
- VmError
Category - Categories of VM errors.