Overview

The Dynamic Swift SDK provides a comprehensive API for building Web3-enabled iOS applications. This reference documents all the functions, types, and utilities available in the SDK.

Core Components

Client & Configuration

  • DynamicClient - Main client for SDK operations
  • DynamicClientConfig - Configuration for initializing the client
  • createDynamicClient - Factory function to create client instances

Session Management

  • DynamicSessionState - Observable session state for SwiftUI
  • bindSessionState - Bind session state for automatic UI updates
  • initializeClient - Initialize client with latest settings
  • addEthereumConnector - Add Ethereum connector to client
  • GenericNetworkConfigurationProvider - Network configuration provider

Authentication

  • sendEmailOtp - Send email OTP for authentication
  • sendSmsOtp - Send SMS OTP for authentication
  • verifyOtp - Verify email OTP codes
  • verifySmsOtp - Verify SMS OTP codes
  • logout - Clear authentication state
  • socialLogin - Authenticate with social providers

Wallet Management

  • createWalletAccount - Create new wallet for authenticated user
  • EthereumWallet - Ethereum wallet instance for transactions
  • loadKeyShares - Load wallet key shares
  • verifySignature - Verify message signatures
  • recoverEncryptedBackupByWallet - Recover wallet key shares
  • exportPrivateKey - Export wallet private key

Ethereum Integration

  • SupportedEthereumNetwork - Supported network configurations
  • EthereumTransaction - Transaction object for sending ETH
  • EthereumAddress - Ethereum address handling
  • BaseEthereumClient - Base network client interface

Data Types

  • SdkUser - Authenticated user information
  • OTPVerification - OTP verification state
  • JwtVerifiedCredential - User’s verified credentials (JWT format)
  • ProviderType - Social authentication provider types

Quick Reference

import DynamicSwiftSDK

// Initialize client with session state
let config = DynamicClientConfig(environmentId: "your-env-id")
let client = createDynamicClient(config: config)
let sessionState = DynamicSessionState()
bindSessionState(sessionState, to: client)

// Add Ethereum connector
try await addEthereumConnector(
    to: client,
    networkConfigProvider: GenericNetworkConfigurationProvider(),
    initialChainId: 84532
)

// Authenticate user
let otpVerification = try await sendEmailOtp(client: client, email: "[email protected]")
let user = try await verifyOtp(otpVerification: otpVerification, verificationToken: "123456")

// Create wallet
let walletAddress = try await createWalletAccount(client: client)

// Initialize wallet
let wallet = try EthereumWallet(address: walletAddress, client: client)

// Send transaction
let tx = EthereumTransaction(from: wallet.address, to: recipient, value: amount, ...)
let txHash = try await wallet.sendTransaction(tx)

// Export private key
let privateKey = try await wallet.exportPrivateKey()

// Recover key shares
let backup = try await recoverEncryptedBackupByWallet(
    client: client,
    walletId: walletId,
    keyShareIds: keyShareIds,
    address: wallet.address.asString()
)
📱 Complete Implementation: For complete working examples of all these functions, check out our Swift Example Repository.

Error Handling

The SDK uses Swift’s native error handling with do-catch blocks. All async functions can throw errors that should be handled appropriately.
do {
    let result = try await someSDKFunction()
} catch {
    print("Error: \(error)")
}

Session State Management

The SDK provides automatic session state management for SwiftUI applications:
@StateObject private var sessionState = DynamicSessionState()

// Bind session state to client
bindSessionState(sessionState, to: client)

// Use in SwiftUI
if sessionState.isLoggedIn {
    // Show authenticated view
} else {
    // Show login view
}

Reference Sections