Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.polygon.technology/llms.txt

Use this file to discover all available pages before exploring further.

The Swift SDK supports email OTP, OIDC ID-token authentication, and OIDC authorization-code redirect authentication. After auth completes, the SDK can automatically select the first existing wallet of the requested type or create one when needed. 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 selects the first matching wallet or creates one when none exists.
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",
    walletType: .ethereum,
    walletSelection: .manual
)

if case let .walletSelection(selection) = selectionResult {
    try await selection.createAndSelectWallet(reference: "main")
}
Parameters
ParameterTypeDescription
codeStringOne-time code entered by the user.
walletTypeWalletTypeOptional wallet type. Defaults to .ethereum.
walletSelectionWalletSelectionBehaviorDefaults to .automatic. Use .manual to receive a pending wallet selection.
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.signInWithOidcToken(
    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.signInWithOidcToken(
    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")
}
signInWithOidcIdToken is also available with the same parameters. 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.
Returns Returns CompleteAuthResult, either .walletSelected(...) or .walletSelection(PendingWalletSelection).

Start OIDC Redirect Auth

Start an OIDC authorization-code PKCE flow and open the returned authorization URL in a browser or ASWebAuthenticationSession.
let redirect = try await oms.wallet.startOidcRedirectAuth(
    provider: OidcProviders.google(),
    redirectUri: "com.example.app:/auth/callback"
)

print("Open:", redirect.authorizationUrl)
Parameters
ParameterTypeDescription
providerOidcProviderConfigOIDC provider configuration.
redirectUriStringApp callback URL that receives the provider redirect.
walletTypeWalletTypeOptional wallet type. Defaults to .ethereum.
relayRedirectUriString?Optional OAuth redirect URI override.
authorizeParams[String: String]Extra authorization query parameters passed to the provider.
Returns Returns StartOidcRedirectAuthResult with authorizationUrl, state, and challenge.

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.
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.