Protocols

The following protocols are available globally.

  • Protocol defining the interface for transaction memos that attach messages or data to Stellar transactions.

    See more

    Declaration

    Swift

    public protocol MemoProtocol : Sendable
  • Protocol for memos containing hash values with hex encoding capabilities.

    See more

    Declaration

    Swift

    public protocol MemoHashProtocol : Sendable
  • Specifies protocol for Account object used when creating an Transaction object.

    See more

    Declaration

    Swift

    public protocol TransactionAccount : Sendable

WebAuthnProvider

  • Platform-specific WebAuthn provider interface.

    Implementations trigger platform biometric / security-key prompts, handle WebAuthn credential creation and assertion, and return properly formatted byte-array results.

    Sendable is required because the protocol crosses actor / task boundaries when invoked from the smart-account transaction pipeline.

    Errors thrown from register or authenticate are subclasses of WebAuthnException (defined in the smart-account error module): RegistrationFailed, AuthenticationFailed, NotSupported, or Cancelled.

    Example:

    let provider: WebAuthnProvider = MyApplePasskeyProvider()
    let registration = try await provider.register(
        challenge: challenge,
        userId: userIdBytes,
        userName: "user@example.com"
    )
    
    See more

    Declaration

    Swift

    public protocol WebAuthnProvider : Sendable
  • Adapter protocol for external Ed25519 signing sources.

    Conform to this protocol to plug in a hardware wallet, remote signing service, or any other out-of-process Ed25519 signing backend into the multi-signer pipeline. The manager consults the adapter before falling back to its in-memory keypair registry (adapter-first precedence rule).

    Example:

    final class MyHardwareWalletAdapter: OZExternalEd25519SignerAdapter {
        func canSignFor(verifierAddress: String, publicKey: Data) -> Bool {
            hardwareWallet.hasSigner(for: publicKey)
        }
    
        func signAuthDigest(authDigest: Data, publicKey: Data) async throws -> Data {
            try await hardwareWallet.sign(digest: authDigest, publicKey: publicKey)
        }
    }
    
    See more

    Declaration

    Swift

    public protocol OZExternalEd25519SignerAdapter : Sendable
  • Base type for OpenZeppelin smart-account signature variants.

    Smart accounts support multiple signature types for transaction authorization:

    Each variant converts to the SCValXDR representation expected by the on-chain verifier contract. The shape differs per variant:

    • WebAuthn: SCValXDR.map with alphabetically-ordered keys.
    • Ed25519: SCValXDR.bytes containing the raw 64-byte signature.
    • Policy: SCValXDR.map([]) (empty map).

    Example:

    let signature = try OZWebAuthnSignature(
        authenticatorData: authenticatorDataBytes,
        clientData: clientDataBytes,
        signature: signatureBytes
    )
    let scVal = signature.toScVal()
    
    See more

    Declaration

    Swift

    public protocol OZSmartAccountSignature : Sendable
  • Represents a signer that can authorize OpenZeppelin Smart Account transactions.

    Smart account signers describe who can authorize transactions on the wallet contract. Two concrete signer types exist:

    • OZDelegatedSigner: A Soroban address (G… for accounts or C… for contracts) using the host’s built-in require_auth verification.
    • OZExternalSigner: A verifier-contract address combined with public-key bytes that describe a custom signature scheme (e.g. WebAuthn / secp256r1, Ed25519).

    Example:

    let delegated = try OZDelegatedSigner(address: "<G-address>")
    let webAuthn = try OZExternalSigner.webAuthn(
        verifierAddress: "CBCD...",
        publicKey: publicKeyBytes,
        credentialId: credentialIdBytes
    )
    let scVal = try delegated.toScVal()
    
    See more

    Declaration

    Swift

    public protocol OZSmartAccountSigner : Sendable
  • Protocol for persisting smart account credentials and sessions.

    Storage adapters provide a pluggable persistence layer for credentials and sessions. Implementations must be thread-safe and support concurrent access.

    The default implementation is OZInMemoryStorageAdapter, which stores data in memory only. Platform-specific implementations can provide persistent storage.

    See more

    Declaration

    Swift

    public protocol OZStorageAdapter : AnyObject, Sendable
  • Protocol for integrating external wallet adapters for multi-signer support.

    External wallet adapters enable signing with external wallets like Freighter or Albedo for multi-signature smart accounts. They handle wallet connection and signature collection.

    Example implementation:

    final class FreighterAdapter: OZExternalWalletAdapter {
        func connect() async throws -> OZConnectedWallet? {
            return OZConnectedWallet(address: "G...", walletId: "freighter", walletName: "Freighter")
        }
        func signAuthEntry(
            preimageXdr: String,
            options: OZSignAuthEntryOptions?
        ) async throws -> OZSignAuthEntryResult {
            // Decode preimage, hash with SHA-256, sign with Ed25519, return result.
        }
        // ... remaining members ...
    }
    
    See more

    Declaration

    Swift

    public protocol OZExternalWalletAdapter : AnyObject, Sendable
  • Protocol for fixed-size binary data wrappers used in XDR encoding.

    WrappedData provides a type-safe way to handle fixed-size byte arrays in Stellar’s XDR protocol. Common sizes include 4, 12, and 32 bytes for various key types and hashes.

    See more

    Declaration

    Swift

    public protocol WrappedData : Equatable, XDRDecodable, XDREncodable
  • A protocol for types which can be decoded from binary.

    See more

    Declaration

    Swift

    public protocol XDRDecodable : Decodable, Sendable
  • A protocol for types which can be encoded to binary.

    See more

    Declaration

    Swift

    public protocol XDREncodable : Encodable, Sendable