OZSmartAccountKit

public final class OZSmartAccountKit : OZSmartAccountKitProtocol, @unchecked Sendable

Primary entry point for OpenZeppelin smart-account operations on Soroban.

The kit is the composition root that owns the operations modules (OZWalletOperations, OZTransactionOperations) and the per-domain managers (OZSignerManager, OZPolicyManager, OZContextRuleManager, OZCredentialManager, OZMultiSignerManager) bound to a single configuration. It also holds the lifetime of the optional indexer and relayer HTTP clients and the shared SorobanServer.

Consumer applications obtain an instance through create(config:); the initializer is internal so direct construction outside the SDK is not permitted. The factory does not perform any network requests — it wires the configuration into the runtime collaborators and returns a ready-to-use kit. Saved sessions are not loaded automatically; call connectWallet(options:) explicitly when session restoration is desired.

Example:

let config = try OZSmartAccountConfig(
    rpcUrl: "https://soroban-testnet.stellar.org",
    networkPassphrase: Network.testnet.passphrase,
    accountWasmHash: "<64-char hex WASM hash>",
    webauthnVerifierAddress: "<C-strkey of WebAuthn verifier contract>"
)
let kit = OZSmartAccountKit.create(config: config)
defer {
    Task { await kit.close() }
}

let wallet = try await kit.walletOperations.createWallet(userName: "My Wallet")
print("Created wallet: \(wallet.contractId)")

Lifecycle

  • disconnect() Asynchronous

    Disconnects the currently connected wallet.

    Clears the in-memory connection state, removes the persisted session via clearSession(), and emits walletDisconnected(contractId:) when a wallet was connected at the time of the call. Stored credentials remain in storage and can be reconnected with connectWallet(options:).

    Safe to call even when no wallet is connected. State is cleared under the lock before storage I/O and event emission so listeners see isConnected == false without deadlock.

    Declaration

    Swift

    public func disconnect() async throws
  • close() Asynchronous

    Closes the kit and releases the HTTP-client and event-emitter resources it owns.

    Closes the shared SorobanServer first so any in-flight RPC traffic is cancelled before the indexer and relayer transports tear down, then closes the indexer client (when present), the relayer client (when present), and removes every listener registered on events. The in-memory connection state is not cleared by close(); call disconnect() first when ending an active session. close() is idempotent.

    Declaration

    Swift

    public func close() async
  • getDeployer() Asynchronous

    Returns the deployer keypair, deriving the default deterministic deployer when no explicit deployer is configured. The result is cached after the first call.

    Throws

    InvalidConfig when default deployer derivation fails.

    Declaration

    Swift

    public func getDeployer() async throws -> KeyPair

    Return Value

    The keypair used to deploy smart-account contracts and to pay transaction fees when no relayer is configured.

Factory

  • Creates a new OZSmartAccountKit for the supplied configuration.

    Wires the configuration’s storage adapter, RPC URL, optional relayer URL, and optional indexer URL into runtime collaborators. The factory does not perform any network requests and does not load any saved session — call connectWallet(options:) after construction when session restoration is desired.

    Declaration

    Swift

    public static func create(config: OZSmartAccountConfig) -> OZSmartAccountKit

    Parameters

    config

    The configuration for the kit.

    Return Value

    A new kit bound to the supplied configuration.