Function estimate_fee

Source
pub async fn estimate_fee<P>(
    envelope: &TransactionEnvelope,
    provider: &P,
    operations_override: Option<usize>,
) -> Result<u64, StellarTransactionUtilsError>
Expand description

Estimate transaction fee in XLM (stroops) based on envelope content

This function intelligently estimates fees by:

  1. Checking if the transaction needs simulation (contains Soroban operations)
  2. If simulation is needed, performs simulation and uses min_resource_fee from the response
  3. If simulation is not needed, counts operations and uses estimate_base_fee

§Arguments

  • envelope - The transaction envelope to estimate fees for
  • provider - Stellar provider for simulation (required if simulation is needed)
  • operations_override - Optional override for operations count (useful when operations will be added, e.g., +1 for fee payment)

§Returns

Estimated fee in stroops (XLM)