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: 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
-
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 -
Request protocol-27 V2 credential arms in the simulation response. Default false.
When
true, the simulation request includes"useUpgradedAuth": true, which instructs a protocol-27 RPC to returnADDRESS_V2credential arms. The key is omitted entirely whenfalse. Emitting V2 on a pre-27 network invalidates the transaction. RPC servers without protocol-27 support silently ignore this flag and return legacyADDRESSentries.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 = false)Parameters
feeThe fee to pay for the transaction in stroops. Default 100.
timeoutInSecondsThe timebounds which should be set for transactions generated by the contract client. Default 300 seconds (5 minutes)
simulateWhether to automatically simulate the transaction when constructing the AssembledTransaction. Default true.
restoreIf true, will automatically attempt to restore the transaction if there are archived entries that need renewal. Default false.
useUpgradedAuthRequest protocol-27 V2 credential arms in the simulation response. Default false.
View on GitHub
Install in Dash