Skip to main content
The Swift SDK supports email OTP and Google sign-in through OIDC ID-token authentication or authorization-code redirect authentication. Authentication returns an active wallet by default. Use manual wallet selection when your app should present wallet choices.

Start Email Auth

Send a one-time code to the user’s email address.
try await oms.wallet.startEmailAuth(email: "user@example.com")
Parameters
ParameterTypeDescription
emailStringEmail address that receives the one-time code.
Returns Returns Void.

Complete Email Auth

Complete the flow with the code entered by the user. Automatic mode returns an active wallet when possible.
let result = try await oms.wallet.completeEmailAuth(code: "123456")

if case let .walletSelected(walletAddress, wallet, _, _) = result {
    print("Wallet address:", walletAddress)
    print("Wallet ID:", wallet.id)
}
Use manual wallet selection when the app needs to choose between wallets before activating one.
let selectionResult = try await oms.wallet.completeEmailAuth(
    code: "123456",
    walletSelection: .manual,
    walletType: .ethereum
)

if case let .walletSelection(selection) = selectionResult {
    try await selection.createAndSelectWallet(reference: "main")
}
Parameters
ParameterTypeDescription
codeStringOne-time code entered by the user.
walletSelectionWalletSelectionBehaviorDefaults to .automatic. Use .manual to receive a pending wallet selection.
walletTypeWalletTypeOptional wallet type. Defaults to .ethereum.
sessionLifetimeSecondsUInt32Optional requested wallet API session lifetime in seconds. Defaults to one week.
Returns Returns CompleteAuthResult, either .walletSelected(...) or .walletSelection(PendingWalletSelection).

Sign In With OIDC Token

Use OIDC ID-token auth for providers such as Google Sign-In. Pass the provider token plus the issuer and audience used to mint it.
let result = try await oms.wallet.signInWithOidcIdToken(
    idToken: googleIdToken,
    issuer: "https://accounts.google.com",
    audience: "YOUR_WEB_CLIENT_ID"
)

if case let .walletSelected(walletAddress, wallet, _, _) = result {
    print("Wallet address:", walletAddress)
    print("Wallet ID:", wallet.id)
}
Use manual wallet selection when the app needs to choose between wallets before activating one.
let result = try await oms.wallet.signInWithOidcIdToken(
    idToken: googleIdToken,
    issuer: "https://accounts.google.com",
    audience: "YOUR_WEB_CLIENT_ID",
    walletSelection: .manual
)

if case let .walletSelection(selection) = result {
    try await selection.createAndSelectWallet(reference: "main")
}
This method accepts the OIDC ID token directly. Use startOidcRedirectAuth and handleOidcRedirectCallback for authorization-code PKCE redirect auth. Parameters
ParameterTypeDescription
idTokenStringOIDC ID token from the identity provider.
issuerStringExpected token issuer, such as https://accounts.google.com.
audienceStringExpected token audience.
walletTypeWalletTypeOptional wallet type. Defaults to .ethereum.
walletSelectionWalletSelectionBehaviorDefaults to .automatic. Use .manual to receive a pending wallet selection.
sessionLifetimeSecondsUInt32Optional requested wallet API session lifetime in seconds. Defaults to one week.
Returns Returns CompleteAuthResult, either .walletSelected(...) or .walletSelection(PendingWalletSelection).

Start OIDC Redirect Auth

Start a Google authorization-code PKCE flow and open the returned authorization URL with a system auth browser.
let redirect = try await oms.wallet.startOidcRedirectAuth(
    provider: OidcProviders.google(),
    redirectUri: "yourapp://auth/callback"
)

print("Open:", redirect.authorizationUrl)
Register the callback scheme, such as yourapp, in your app target before using redirect auth. Parameters
ParameterTypeDescription
providerOidcProviderConfigGoogle provider configuration returned by OidcProviders.google().
redirectUriStringApp callback URL that receives the provider redirect. Configure this URL scheme or universal link in the app target.
walletTypeWalletTypeOptional wallet type. Defaults to .ethereum.
loginHintString?Optional Google login_hint. When omitted for Google, the SDK can reuse the previous session email.
authorizeParams[String: String]Extra authorization query parameters passed to the provider.
Returns Returns StartOidcRedirectAuthResult with the provider authorizationUrl. state and challenge are SDK-managed values.

Handle OIDC Redirect Callback

Pass incoming app-link URLs to the callback handler. It is safe to call for unrelated links.
let result = try await oms.wallet.handleOidcRedirectCallback(callbackUrl)

switch result {
case .completed(let wallet):
    print("Wallet address:", wallet.address)
case .walletSelection(let selection):
    try await selection.createAndSelectWallet()
case .notOidcRedirectCallback, .noPendingAuth:
    break
case .failed(let error):
    throw error
}
Parameters
ParameterTypeDescription
callbackUrlString?Incoming app-link URL.
walletSelectionWalletSelectionBehaviorDefaults to .automatic. Use .manual to receive a pending wallet selection.
sessionLifetimeSecondsUInt32Optional requested wallet API session lifetime in seconds. Defaults to one week.
Returns Returns OidcRedirectAuthResult.

Use Wallet

Activate an existing wallet by server-side wallet ID.
try await oms.wallet.useWallet(walletId: "wallet-id")
Parameters
ParameterTypeDescription
walletIdStringWallet ID returned by auth completion or listWallets().
Returns Returns WalletActivationResult.

Create Wallet

Create and activate a new wallet for the authenticated user.
let result = try await oms.wallet.createWallet(reference: "main")

print("New wallet:", result.walletAddress)
Parameters
ParameterTypeDescription
walletTypeWalletTypeWallet type to create. Defaults to .ethereum.
referenceString?Optional app-defined wallet reference.
Returns Returns WalletActivationResult.