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)")
-
The configuration the kit was constructed with.
Declaration
Swift
public let config: OZSmartAccountConfig -
Optional indexer client used for credential-to-contract discovery.
Present when
effectiveIndexerUrl()resolves to a non-nilURL atcreate(config:)time. The kit owns the lifetime and invalidates the underlyingURLSessiononclose().Declaration
Swift
public let indexerClient: OZIndexerClient? -
Optional relayer client used for fee-sponsored transaction submission.
Present when
relayerUrlis non-nilatcreate(config:)time. The kit owns the lifetime and invalidates the underlyingURLSessiononclose().Declaration
Swift
public let relayerClient: OZRelayerClient? -
Event emitter shared by every manager bound to this kit.
A single
OZSmartAccountEventEmitterinstance is created at kit construction time and exposed to consumers and to the wallet- and transaction-operations modules. Lifecycle and credential-lifecycle listeners installed here observe events from every manager belonging to the same kit.Declaration
Swift
public let events: OZSmartAccountEventEmitter -
Wallet-operations module bound to this kit. Traps if accessed after
close().Declaration
Swift
public var walletOperations: OZWalletOperations { get } -
Transaction-operations module bound to this kit.
Traps if accessed after
close().Declaration
Swift
public var transactionOperations: OZTransactionOperations { get } -
Signer manager bound to this kit.
Traps if accessed after
close().Declaration
Swift
public var signerManager: OZSignerManager { get } -
Policy manager bound to this kit.
Traps if accessed after
close().Declaration
Swift
public var policyManager: OZPolicyManager { get } -
Context-rule manager bound to this kit.
Traps if accessed after
close().Declaration
Swift
public var contextRuleManager: OZContextRuleManager { get } -
Credential manager bound to this kit.
Traps if accessed after
close().Declaration
Swift
public var credentialManager: OZCredentialManager { get } -
Multi-signer manager bound to this kit.
Traps if accessed after
close().Declaration
Swift
public var multiSignerManager: OZMultiSignerManager { get } -
Kit-owned external-signer manager. The single front door for all external (non-passkey) signing sources.
Constructed at kit initialization from
externalWalletandexternalEd25519Adapter. Always non-nil; remains valid afterclose(). Register in-memory keypairs at runtime viaaddFromSecret(secretKey:)andaddEd25519FromRawKey(secretKeyBytes:verifierAddress:).Declaration
Swift
public var externalSigners: OZExternalSignerManager { get } -
Indicates whether a wallet is currently connected.
A wallet is connected when both the credential id and the contract id are set. This property reflects in-memory state only; after an app restart consumers should call
connectWallet(options:)to restore a saved session.Declaration
Swift
public var isConnected: Bool { get } -
The credential identifier of the currently connected wallet, when a wallet is connected.
Returns
nilwhen no wallet is connected. The credential id is Base64URL-encoded without padding, matching the WebAuthn specification.Declaration
Swift
public var credentialId: String? { get } -
The contract address of the currently connected wallet, when a wallet is connected.
Returns
nilwhen no wallet is connected. The contract id is a Stellar C-strkey (56 characters, starting withC).Declaration
Swift
public var contractId: String? { get }
-
disconnect()AsynchronousDisconnects the currently connected wallet.
Clears the in-memory connection state, removes the persisted session via
clearSession(), and emitswalletDisconnected(contractId:)when a wallet was connected at the time of the call. Stored credentials remain in storage and can be reconnected withconnectWallet(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 == falsewithout deadlock.Declaration
Swift
public func disconnect() async throws -
close()AsynchronousCloses the kit and releases the HTTP-client and event-emitter resources it owns.
Closes the shared
SorobanServerfirst 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 onevents. The in-memory connection state is not cleared byclose(); calldisconnect()first when ending an active session.close()is idempotent.Declaration
Swift
public func close() async -
getDeployer()AsynchronousReturns the deployer keypair, deriving the default deterministic deployer when no explicit deployer is configured. The result is cached after the first call.
Throws
InvalidConfigwhen default deployer derivation fails.Declaration
Swift
public func getDeployer() async throws -> KeyPairReturn Value
The keypair used to deploy smart-account contracts and to pay transaction fees when no relayer is configured.
-
Creates a new
OZSmartAccountKitfor 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) -> OZSmartAccountKitParameters
configThe configuration for the kit.
Return Value
A new kit bound to the supplied configuration.
View on GitHub
Install in Dash