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)
  • UseUpgradedAuth: Request protocol-27 V2 credential arms in the simulation response (default: true)

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
  • Selects the credential arm the simulation records. Default true.

    When true (the default), the simulation requests ADDRESS_V2 credential arms; when false, legacy ADDRESS arms. The flag is forwarded to the simulation request and always sent in the JSON-RPC params. Set to false on a network below protocol 27, where V2 arms invalidate the transaction. RPC servers without protocol-27 support silently ignore this flag and return legacy ADDRESS entries.

    Declaration

    Swift

    public let useUpgradedAuth: Bool
  • Constructor

    Declaration

    Swift

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

    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.

    useUpgradedAuth

    Request protocol-27 V2 credential arms in the simulation response; false requests legacy ADDRESS arms. Default true.