OZTransactionOperations

Transaction operations for OpenZeppelin Smart Accounts.

Provides high-level transaction building, signing, and submission capabilities for smart account operations. Handles:

  • Token transfers with automatic stroops conversion

  • Transaction simulation and fee estimation

  • Authorization entry signing with WebAuthn

  • Relayer submission for fee sponsoring

  • Transaction polling and confirmation

  • Testnet wallet funding via Friendbot

Fee Sponsoring

When a relayer URL is configured via config.relayerUrl, transactions can be fee-sponsored by the relayer. Two modes are used depending on authorization entry types:

  • Mode 1 (Host Function + Auth): Used when no source_account auth exists. Sends host function and signed auth entries. Transaction is not signed by source account.

  • Mode 2 (Signed Transaction XDR): Used when source_account auth exists. Sends fully signed transaction XDR. Required for operations that need source account signature.

The mode is automatically selected based on the presence of source_account (Void) credentials in the authorization entries.

This class works in tandem with OZSmartAccountKit and should be accessed via the kit instance rather than instantiated directly.

Example usage:

val kit = OZSmartAccountKit.create(config)
val txOps = OZTransactionOperations(kit)

// Transfer tokens
val result = txOps.transfer(
tokenContract = nativeTokenAddress,
recipient = "GA7Q...",
amount = "100"
)
println("Transfer ${if (result.success) "succeeded" else "failed"}")

// Fund testnet wallet
val fundedAmount = txOps.fundWallet(nativeTokenContract = nativeTokenAddress)
println("Funded with $fundedAmount XLM")

See also

for fee sponsoring mode selection logic

for testnet funding with relayer support

Functions

Link copied to clipboard
suspend fun contractCall(target: String, targetFn: String, targetArgs: List<SCValXdr> = emptyList(), forceMethod: SubmissionMethod? = null, resolveContextRuleIds: ResolveContextRuleIds? = null): TransactionResult

Calls an arbitrary function on an external contract directly from the smart account.

Link copied to clipboard
suspend fun executeAndSubmit(target: String, targetFn: String, targetArgs: List<SCValXdr> = emptyList(), forceMethod: SubmissionMethod? = null, resolveContextRuleIds: ResolveContextRuleIds? = null): TransactionResult

Executes an arbitrary contract function call through the smart account's execute entry point.

Link copied to clipboard
suspend fun fundWallet(nativeTokenContract: String, forceMethod: SubmissionMethod? = null): String

Funds the smart account wallet using Friendbot (testnet only).

Link copied to clipboard
suspend fun submit(hostFunction: HostFunctionXdr, auth: List<SorobanAuthorizationEntryXdr>, forceMethod: SubmissionMethod? = null, resolveContextRuleIds: ResolveContextRuleIds? = null): TransactionResult

Submits a host function with full Soroban authorization flow.

Link copied to clipboard
suspend fun transfer(tokenContract: String, recipient: String, amount: String, forceMethod: SubmissionMethod? = null): TransactionResult

Transfers tokens from the smart account to a recipient.