transfer
Transfers tokens from the smart account to a recipient.
Works with any SEP-41 compatible token (XLM via SAC, custom Soroban tokens). The amount is a decimal string converted to stroops (7 decimal places) internally.
Flow:
Validates recipient address and prevents self-transfer
Converts amount to stroops using BigInteger arithmetic
Delegates to contractCall which builds the host function, simulates, signs auth entries via WebAuthn, re-simulates, and submits
IMPORTANT: This method requires WebAuthn interaction to sign auth entries. The user will be prompted for biometric authentication.
Return
TransactionResult indicating success or failure
Parameters
The token contract address (C-address). Use the SAC address for XLM or the token's contract address for custom tokens.
The recipient address (G-address for accounts, C-address for contracts)
Decimal amount string (e.g., "10", "100.5"). Converted to stroops automatically.
Optional override to force relayer or RPC submission (default: auto-detect)
Throws
if no wallet is connected
if recipient address is invalid or same as smart account
if amount is not a valid positive decimal
if simulation, signing, or submission fails
if biometric authentication fails
Example:
val result = txOps.transfer(
tokenContract = "CBCD1234...",
recipient = "GA7QYNF7...",
amount = "10.5"
)
if (result.success) {
println("Transferred. Hash: ${result.hash ?: ""}")
} else {
println("Transfer failed: ${result.error ?: ""}")
}