OZSmartAccountConfig
public struct OZSmartAccountConfig : @unchecked Sendable
extension OZSmartAccountConfig: Equatable
extension OZSmartAccountConfig: Hashable
Configuration for OpenZeppelin Smart Account operations.
Defines all parameters required to interact with OpenZeppelin smart accounts on Stellar/Soroban: network connectivity, contract addresses, and operational defaults.
Example:
let config = try OZSmartAccountConfig(
rpcUrl: "https://soroban-testnet.stellar.org",
networkPassphrase: "Test SDF Network ; September 2015",
accountWasmHash: "abc123...",
webauthnVerifierAddress: "CBCD1234..."
)
let custom = try OZSmartAccountConfig.builder(
rpcUrl: "https://soroban-testnet.stellar.org",
networkPassphrase: "Test SDF Network ; September 2015",
accountWasmHash: "abc123...",
webauthnVerifierAddress: "CBCD1234..."
)
.sessionExpiryMs(86_400_000)
.relayerUrl("https://relayer.example.com")
.storage(myPersistentStorage)
.externalWallet(freighterAdapter)
.build()
Throws SmartAccountConfigurationException if required parameters are blank or invalid (for
example, accountWasmHash is not a 64-character hex string, or
webauthnVerifierAddress is not a valid C-address).
-
The Soroban RPC endpoint URL.
Example:
https://soroban-testnet.stellar.org.Declaration
Swift
public let rpcUrl: String -
The Stellar network passphrase.
Examples:
- Testnet:
"Test SDF Network ; September 2015" - Mainnet:
"Public Global Stellar Network ; September 2015"
Declaration
Swift
public let networkPassphrase: String - Testnet:
-
The WASM hash of the smart account contract (64-character hex string).
SHA-256 of the smart account contract WASM code, used for deploying new smart account instances.
Declaration
Swift
public let accountWasmHash: String -
The contract address of the WebAuthn signature verifier (
C…strkey).Validates secp256r1 signatures from WebAuthn / passkeys.
Declaration
Swift
public let webauthnVerifierAddress: String
-
The keypair used for deploying smart account contracts.
When
nil, a deterministic deployer is derived fromSHA-256("openzeppelin-smart-account-kit"). Production apps typically supply a custom deployer for attribution and traceability. The deployer only pays for deployment transactions; it does not control user wallets.Declaration
Swift
public let deployerKeypair: KeyPair? -
Session expiry time in milliseconds.
Sessions enable silent reconnection without re-authentication.
Declaration
Swift
public let sessionExpiryMs: Int64 -
Signature expiration in ledgers for auth entries.
Auth entries expire after this many ledgers to prevent replay attacks. Default approximates one hour at five seconds per ledger. Must be
>= 1. There is no client-side upper bound; the network’smaxEntryTTL(CAP-0046-11) governs the maximum and is enforced by the host at submission.Declaration
Swift
public let signatureExpirationLedgers: Int -
Transaction validity window in seconds.
Sets each transaction’s
TimeBoundsmax_timetonow + timeoutInSeconds, bounding how long a signed transaction stays valid for submission. A value of0means no expiry (infinite):max_timeis set to0, the Stellar sentinel for “no upper bound”. Must be>= 0. Default is30.Declaration
Swift
public let timeoutInSeconds: Int -
Optional relayer endpoint URL for fee sponsoring.
When set, enables gasless transactions by submitting through a fee-bump relayer. Allows users with empty wallets to transact.
Declaration
Swift
public let relayerUrl: String? -
Optional indexer endpoint URL for credential-to-contract mapping.
The indexer maps WebAuthn credential IDs to deployed smart account contract addresses, enabling “Connect Wallet” functionality where users can discover previously-created wallets.
Declaration
Swift
public let indexerUrl: String? -
Optional WebAuthn provider for passkey authentication.
Platform-specific implementation that handles WebAuthn registration and authentication. Required for signing transactions with passkeys.
Declaration
Swift
public let webauthnProvider: WebAuthnProvider? -
Storage adapter for persisting credentials and session data.
Defaults to
OZInMemoryStorageAdapter(non-persistent, suitable for testing).Declaration
Swift
public let storage: OZStorageAdapter -
When set, delegates transaction signing to this adapter instead of using WebAuthn credentials.
Declaration
Swift
public let externalWallet: OZExternalWalletAdapter? -
Optional adapter for out-of-process Ed25519 signing in multi-signer ceremonies.
When non-
nil, the adapter is injected into the kit’sOZExternalSignerManagerat construction time and consulted (with adapter-first precedence) before the in-memory Ed25519 keypair registry for everyed25519(verifierAddress:publicKey:)entry. In-memory keypairs can still be registered at runtime viaexternalSignersaddEd25519FromRawKey(secretKeyBytes:verifierAddress:).Declaration
Swift
public let externalEd25519Adapter: OZExternalEd25519SignerAdapter? -
Maximum rule ID to scan when iterating context rules.
The contract assigns monotonically increasing IDs to context rules. When rules are removed, their IDs leave gaps. Iterating from ID
0up to this value finds all active rules. Increase if the account has had many add / remove cycles.Declaration
Swift
public let maxContextRuleScanId: UInt32
-
init(rpcUrl:networkPassphrase: accountWasmHash: webauthnVerifierAddress: deployerKeypair: sessionExpiryMs: signatureExpirationLedgers: timeoutInSeconds: relayerUrl: indexerUrl: webauthnProvider: storage: externalWallet: externalEd25519Adapter: maxContextRuleScanId: ) Initializes a new
OZSmartAccountConfig.Throws
SmartAccountConfigurationException.MissingConfigfor blank required strings;SmartAccountConfigurationException.InvalidConfigfor malformedaccountWasmHashorwebauthnVerifierAddress.Declaration
Swift
public init( rpcUrl: String, networkPassphrase: String, accountWasmHash: String, webauthnVerifierAddress: String, deployerKeypair: KeyPair? = nil, sessionExpiryMs: Int64 = OZConstants.defaultSessionExpiryMs, signatureExpirationLedgers: Int = StellarProtocolConstants.ledgersPerHour, timeoutInSeconds: Int = OZConstants.defaultTimeoutSeconds, relayerUrl: String? = nil, indexerUrl: String? = nil, webauthnProvider: WebAuthnProvider? = nil, storage: OZStorageAdapter = OZInMemoryStorageAdapter(), externalWallet: OZExternalWalletAdapter? = nil, externalEd25519Adapter: OZExternalEd25519SignerAdapter? = nil, maxContextRuleScanId: UInt32 = 50 ) throws
-
createDefaultDeployer()AsynchronousCreates a deterministic deployer keypair for smart account deployment.
Derives a keypair from
SHA-256("openzeppelin-smart-account-kit"). The derivation is deterministic, so the same deployer is produced on every invocation unless overridden. This keypair only pays deployment fees and does not control user wallets. Production apps typically supply a custom deployer for attribution and traceability.Throws
SmartAccountConfigurationException.InvalidConfigif seed generation fails.Declaration
Swift
public static func createDefaultDeployer() async throws -> KeyPairReturn Value
A deterministic
KeyPairfor contract deployment. -
Creates a builder for constructing
OZSmartAccountConfigwith a fluent API.Declaration
Swift
public static func builder( rpcUrl: String, networkPassphrase: String, accountWasmHash: String, webauthnVerifierAddress: String ) -> BuilderParameters
rpcUrlThe Soroban RPC endpoint URL.
networkPassphraseThe Stellar network passphrase.
accountWasmHashThe smart account contract WASM hash (64-char hex).
webauthnVerifierAddressThe WebAuthn verifier contract address (
C…strkey).Return Value
A new
Builderwith the four required fields set and defaults applied to every optional field.
-
effectiveDeployer()AsynchronousReturns the deployer keypair, creating the default if needed.
Async because creating the default deployer involves cryptographic operations (SHA-256 hashing and Ed25519 seed derivation).
Throws
SmartAccountConfigurationException.InvalidConfigif default deployer creation fails.Declaration
Swift
public func effectiveDeployer() async throws -> KeyPairReturn Value
The configured deployer or the default deterministic deployer.
-
Returns the indexer URL that will be used after applying fallback logic.
If an indexer URL is explicitly configured, it is returned. Otherwise the built-in default for the configured network passphrase is returned, sourced from
OZIndexerClient.getDefaultUrl(networkPassphrase:). Returnsnilwhen no URL is configured and no default exists for the network.Declaration
Swift
public func effectiveIndexerUrl() -> String?Return Value
The resolved indexer URL, or
nil.
-
Builder for creating
OZSmartAccountConfigwith a fluent API.Example:
See morelet config = try OZSmartAccountConfig.builder( rpcUrl: "https://soroban-testnet.stellar.org", networkPassphrase: "Test SDF Network ; September 2015", accountWasmHash: "abc123...", webauthnVerifierAddress: "CBCD1234..." ) .sessionExpiryMs(86_400_000) .relayerUrl("https://relayer.example.com") .storage(myPersistentStorage) .externalWallet(freighterAdapter) .build()Declaration
Swift
public final class Builder : @unchecked Sendable
-
Two configurations are equal when every field compares equal.
KeyPairand the protocol-typedstorage,webauthnProvider, andexternalWalletfields use reference / instance equality where applicable.OZInMemoryStorageAdapteroverrides equality so all instances of that class compare equal, which lets two default-constructed configs round-trip through equality without surprises.Declaration
Swift
public static func == (lhs: OZSmartAccountConfig, rhs: OZSmartAccountConfig) -> Bool -
Declaration
Swift
public func hash(into hasher: inout Hasher)
View on GitHub
Install in Dash