Skip to content

zerodevapp/omni-sdk-swift-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gas Sponsorship Demo — ZeroDev + Privy (Swift)

A SwiftUI app demonstrating gasless smart account transactions using ZeroDev Omni SDK for ERC-4337 account abstraction and Privy for authentication + embedded wallet signing.

Works on both macOS and iOS.

What it does

  1. Login — User authenticates via email OTP (Privy)
  2. Embedded wallet — Privy creates a secure embedded Ethereum wallet
  3. Smart account — ZeroDev creates a Kernel v3.3 smart account with the Privy wallet as owner
  4. Gas sponsorship — ZeroDev's paymaster sponsors all gas fees (user pays nothing)
  5. Send transaction — Gasless UserOp from the smart account, confirmed on Sepolia

Architecture

┌──────────────┐     ┌─────────────────────┐     ┌───────────────────┐
│  Privy SDK   │────>│  PrivySigner        │────>│  ZeroDev Omni SDK │
│  (auth +     │     │  (AsyncSignerProto  │     │  (Kernel v3.3 +   │
│   embedded   │     │   bridges EIP-1193  │     │   paymaster +     │
│   wallet)    │     │   to ZeroDev)       │     │   URLSession)     │
└──────────────┘     └─────────────────────┘     └───────────────────┘

Key integration points:

  • AsyncSignerProtocol — Privy's async wallet provider maps directly to ZeroDev's async signer interface. No semaphores, no deadlocks.
  • useURLSessionTransport() — Routes all SDK HTTP through Apple's URLSession instead of Zig's TLS client. Required on iOS, optional on macOS.

Setup

  1. Copy the env file and fill in your credentials:

    cp .env.example .env
    ZERODEV_PROJECT_ID=...   # from dashboard.zerodev.app
    PRIVY_APP_ID=...         # from dashboard.privy.io
    PRIVY_CLIENT_ID=...      # from dashboard.privy.io (starts with "client-")
    
  2. Run:

    make run       # macOS
    make run-ios   # iOS Simulator (boots iPhone 17 Pro by default)

    Use a different simulator with: make run-ios SIMULATOR="iPhone 17e"

That's it. No Zig, no local SDK builds — the ZeroDev Omni SDK is pulled as a pre-built xcframework via SPM.

File structure

Sources/
├── GasSponsorshipApp.swift   # @main entry, Privy SDK init
├── Config.swift              # Reads credentials from environment / .env
├── PrivySigner.swift         # AsyncSignerProtocol: Privy wallet → ZeroDev signer
├── WalletManager.swift       # Auth → wallet → smart account state machine
├── RootView.swift            # Navigation router based on auth state
├── LoginView.swift           # Email input screen
├── OTPView.swift             # OTP verification screen
└── DashboardView.swift       # Wallet dashboard + send transaction

Dependencies

Both pulled automatically via Swift Package Manager:

  • zerodev-omni-sdk v0.0.1-alpha.2 — ERC-4337 smart account SDK (pre-built xcframework)
  • privy-ios v2.10.0 — Auth + embedded wallets

About

Gasless smart account Swift app: ZeroDev Omni SDK + Privy (iOS/macOS)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors