OZSmartAccountKit

Main orchestrator for OpenZeppelin Smart Account operations on Stellar/Soroban.

OZSmartAccountKit is the primary entry point for creating and managing smart accounts with WebAuthn/passkey authentication. It provides a high-level interface for:

  • Creating new smart account wallets with biometric authentication

  • Connecting to existing wallets via credential discovery

  • Managing wallet sessions and credentials

  • Submitting transactions with WebAuthn signatures

  • Interacting with signers, policies, and context rules

The kit orchestrates multiple components:

  • Storage adapter for credential persistence

  • Soroban RPC server for blockchain interaction

  • Relayer client for fee-sponsored transactions (optional)

  • Indexer client for credential-to-contract discovery (optional)

Example usage:

// Initialize the kit
val config = OZSmartAccountConfig(
rpcUrl = "https://soroban-testnet.stellar.org",
networkPassphrase = "Test SDF Network ; September 2015",
accountWasmHash = "abc123...",
webauthnVerifierAddress = "CBCD1234...",
relayerUrl = "https://relayer.example.com",
indexerUrl = "https://indexer.example.com"
)
val kit = OZSmartAccountKit.create(config)

// Create a new wallet (prompts for biometric authentication)
val wallet = kit.walletOperations.createWallet(userName = "My Wallet")
println("Created wallet: ${wallet.contractId}")

// Silent session check (returns null if no valid session)
val existing = kit.walletOperations.connectWallet()
if (existing != null) {
println("Connected to: ${existing.contractId}")
}

// Session check with WebAuthn fallback if no session
val connected = kit.walletOperations.connectWallet(
OZWalletOperations.ConnectWalletOptions(prompt = true)
)
println("Connected to: ${connected?.contractId}")

// Explicit connect with fresh WebAuthn prompt (skips session restore)
val fresh = kit.walletOperations.connectWallet(
OZWalletOperations.ConnectWalletOptions(fresh = true)
)
println("Authenticated and connected to: ${fresh?.contractId}")

// Disconnect
kit.disconnect()

Thread Safety: This class is thread-safe. All internal state is protected by a Mutex. Public methods can be safely called from any coroutine context.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The configuration defining network endpoints, contract addresses, and operational parameters.

Link copied to clipboard

Manages context rule operations (creating, updating, removing rules).

Link copied to clipboard

The contract address of the currently connected wallet.

Link copied to clipboard

The credential ID of the currently connected wallet.

Link copied to clipboard

Manages credential operations (storing, retrieving, updating credentials).

Link copied to clipboard

Event emitter for wallet lifecycle events.

Link copied to clipboard

Optional indexer client for credential-to-contract discovery. Null when no indexer URL is configured.

Link copied to clipboard

Indicates whether a wallet is currently connected.

Link copied to clipboard

Manages multi-signer operations (coordinating multiple signers).

Link copied to clipboard

Manages policy operations (installing, removing, querying policies).

Link copied to clipboard

Optional relayer client for fee-sponsored transaction submission. Null when no relayer URL is configured.

Link copied to clipboard

Manages signer operations (adding, removing, querying signers).

Link copied to clipboard

Manages transaction operations (building, signing, submitting).

Link copied to clipboard

Manages wallet operations (creation, connection, disconnection).

Functions

Link copied to clipboard
fun close()

Closes this kit and releases all held HTTP client resources.

Link copied to clipboard
suspend fun disconnect()

Disconnects the currently connected wallet.