MethodOptions

public final class MethodOptions : Sendable

Transaction configuration options for contract method invocations.

MethodOptions allows fine-tuning of transaction behavior when invoking contract methods through SorobanClient or AssembledTransaction.

Configuration parameters:

  • Fee: Base fee in stroops (default: 100)
  • Timeout: Transaction validity window (default: 300 seconds)
  • Simulate: Auto-simulate before submission (default: true)
  • Restore: Auto-restore archived entries if needed (default: false)

Example:

// Custom method options for a high-priority transaction
let methodOptions = MethodOptions(
    fee: 10000,           // Higher fee for faster inclusion
    timeoutInSeconds: 60,  // Shorter validity window
    simulate: true,        // Auto-simulate
    restore: true          // Auto-restore if needed
)

let result = try await client.invokeMethod(
    name: "transfer",
    args: [from, to, amount],
    methodOptions: methodOptions
)

See also:

  • [SorobanClient.invokeMethod] for using method options
  • [AssembledTransaction] for transaction construction
  • [ClientOptions] for client-level configuration
  • fee

    The fee to pay for the transaction in stroops. Default 100.

    Declaration

    Swift

    public let fee: UInt32
  • The timebounds which should be set for transactions generated by the contract client. Default 300 seconds (5 minutes)

    Declaration

    Swift

    public let timeoutInSeconds: UInt64
  • Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default true.

    Declaration

    Swift

    public let simulate: Bool
  • If true, will automatically attempt to restore the transaction if there are archived entries that need renewal. Default false.

    Declaration

    Swift

    public let restore: Bool
  • Constructor

    Declaration

    Swift

    public init(fee: UInt32 = Transaction.minBaseFee, timeoutInSeconds: UInt64 = NetworkConstants.DEFAULT_TIMEOUT_SECONDS, simulate: Bool = true, restore: Bool = false)

    Parameters

    fee

    The fee to pay for the transaction in stroops. Default 100.

    timeoutInSeconds

    The timebounds which should be set for transactions generated by the contract client. Default 300 seconds (5 minutes)

    simulate

    Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default true.

    restore

    If true, will automatically attempt to restore the transaction if there are archived entries that need renewal. Default false.