OZWalletOperations
public final class OZWalletOperations : OZManagerHelpers, @unchecked Sendable
Wallet-lifecycle operations for OpenZeppelin Smart Accounts.
Handles wallet creation (WebAuthn registration + deterministic contract derivation + deploy-transaction build and submission), wallet connection (session restore, storage → derivation → indexer cascade, ambiguous-multi- contract handling), standalone passkey authentication, and retry of a previously deferred or failed deployment.
Instances are constructed by OZSmartAccountKit and accessed through
kit.walletOperations.
-
Creates a new smart-account wallet backed by a fresh WebAuthn credential.
Registers a passkey, derives the deterministic contract address, builds and signs the deploy transaction, and optionally submits it. The signed deploy XDR is always present in the result for deferred submission.
Declaration
Swift
public func createWallet( userName: String = "Smart Account User", autoSubmit: Bool = false, autoFund: Bool = false, nativeTokenContract: String? = nil, forceMethod: OZSubmissionMethod? = nil ) async throws -> OZCreateWalletResultParameters
userNameDisplay name persisted with the credential.
autoSubmitWhen
true, submits the deploy transaction immediately (defaultfalse). ThesignedTransactionXdrfield of the result carries the signed envelope for later external submission regardless.autoFundFund the freshly deployed wallet via Friendbot (testnet only). Requires
autoSubmit = trueandnativeTokenContract != nil.nativeTokenContractNative token (XLM SAC) contract address used when
autoFund = true.forceMethodOptional submission-method override.
Return Value
OZCreateWalletResultdescribing the new wallet. -
connectWallet(options:Asynchronous) Connects to an existing smart-account wallet.
Returns
OZConnectWalletResulton success, ornilwhen no valid session exists andoptions.prompt == false. The non-nilresult is either anconnected(credentialId:contractId:restoredFromSession:)arm (single contract resolved, kit state set, session saved) or aambiguous(credentialId:candidates:)arm (indexer reported multiple contracts — kit state NOT set, caller must let the user pick).Throws
WebAuthnException(prompt path),SmartAccountWalletException(no contract resolved),SmartAccountValidationException(options validation),SmartAccountTransactionException(RPC failure),SmartAccountIndexerException(indexer transport failure).Declaration
Swift
public func connectWallet( options: OZConnectWalletOptions = OZConnectWalletOptions() ) async throws -> OZConnectWalletResult?Parameters
optionsConnect-wallet options. Defaults to a silent session-only restore.
Return Value
OZConnectWalletResultornil. -
authenticatePasskey(challenge:AsynchronouscredentialIds: ) Authenticates with a passkey without connecting to a wallet.
Used to authenticate the user before contract selection (for example to discover deployed contracts via the indexer) or for multi-signer operations that do not require a fully-connected kit state.
Throws
WebAuthnException(authentication failure / no provider),SmartAccountValidationException(signature normalisation failure).Declaration
Swift
public func authenticatePasskey( challenge: Data? = nil, credentialIds: [String]? = nil ) async throws -> OZAuthenticatePasskeyResultParameters
challengeOptional challenge bytes to sign. When
nil, a fresh 32-byte random challenge is generated.credentialIdsOptional list of allowed credential ids (Base64URL-encoded). When provided, only those credentials may be used by the authenticator.
Return Value
OZAuthenticatePasskeyResultcarrying the credential id, normalised signature, and stored public key (when available). -
deployPendingCredential(credentialId:AsynchronousautoSubmit: autoFund: nativeTokenContract: forceMethod: ) Deploys a wallet from a previously created pending credential.
Used to retry a failed deployment or to submit a wallet created with
createWallet(autoSubmit: false). The credential must exist in storage with a validpublicKeyandcontractId.Declaration
Swift
public func deployPendingCredential( credentialId: String, autoSubmit: Bool = true, autoFund: Bool = false, nativeTokenContract: String? = nil, forceMethod: OZSubmissionMethod? = nil ) async throws -> OZDeployPendingResultParameters
credentialIdBase64URL-encoded credential identifier of the credential to deploy.
autoSubmitWhether to submit the deploy transaction. Defaults to
true(this entry point is typically used to retry a failed deploy so callers usually want submission).autoFundWhether to fund the freshly deployed wallet using Friendbot (testnet only). Requires
autoSubmit = true.nativeTokenContractNative token contract address used when
autoFund = true.forceMethodOptional submission-method override.
Return Value
OZDeployPendingResultdescribing the deployment.
View on GitHub
Install in Dash