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
| Parameter | Type | Description |
|---|
email | String | Email 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
| Parameter | Type | Description |
|---|
code | String | One-time code entered by the user. |
walletType | WalletType | Optional wallet type. Defaults to .ethereum. |
walletSelection | WalletSelectionBehavior | Defaults 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
| Parameter | Type | Description |
|---|
idToken | String | OIDC ID token from the identity provider. |
issuer | String | Expected token issuer, such as https://accounts.google.com. |
audience | String | Expected token audience. |
walletType | WalletType | Optional wallet type. Defaults to .ethereum. |
walletSelection | WalletSelectionBehavior | Defaults 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
| Parameter | Type | Description |
|---|
provider | OidcProviderConfig | OIDC provider configuration. |
redirectUri | String | App callback URL that receives the provider redirect. |
walletType | WalletType | Optional wallet type. Defaults to .ethereum. |
relayRedirectUri | String? | 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
| Parameter | Type | Description |
|---|
callbackUrl | String? | Incoming app-link URL. |
walletSelection | WalletSelectionBehavior | Defaults 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
| Parameter | Type | Description |
|---|
walletId | String | Wallet 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
| Parameter | Type | Description |
|---|
walletType | WalletType | Wallet type to create. Defaults to .ethereum. |
reference | String? | Optional app-defined wallet reference. |
Returns
Returns WalletActivationResult.