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 Kotlin 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.
client.wallet.startEmailAuth("user@example.com")
Parameters
ParameterTypeDescription
emailStringEmail address that receives the one-time code.
Returns Returns Unit.

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.
import com.omsclient.kotlin_sdk.wallet.CompleteAuthResult

val result = client.wallet.completeEmailAuth("123456")
check(result is CompleteAuthResult.WalletSelected)

println("Wallet address: ${result.walletAddress}")
println("Wallet ID: ${result.wallet.id}")
Use manual wallet selection when the app needs to choose between wallets before activating one.
import com.omsclient.kotlin_sdk.wallet.CompleteAuthResult
import com.omsclient.kotlin_sdk.wallet.WalletSelectionBehavior

val selectionResult = client.wallet.completeEmailAuth(
    code = "123456",
    walletSelection = WalletSelectionBehavior.Manual,
)
check(selectionResult is CompleteAuthResult.WalletSelection)

selectionResult.pendingSelection.createAndSelectWallet(reference = "main")
Parameters
ParameterTypeDescription
codeStringOne-time code entered by the user.
walletSelectionWalletSelectionBehaviorDefaults to WalletSelectionBehavior.Automatic.
walletTypeWalletTypeOptional wallet type. Defaults to WalletType.Ethereum.
Returns Returns CompleteAuthResult, either WalletSelected or WalletSelection.

Sign In With OIDC ID Token

Use OIDC ID-token auth for providers such as Google Sign-In with Android Credential Manager.
import com.omsclient.kotlin_sdk.wallet.CompleteAuthResult

val result = client.wallet.signInWithOidcIdToken(
    idToken = googleIdToken,
    issuer = "https://accounts.google.com",
    audience = "YOUR_WEB_CLIENT_ID",
)
check(result is CompleteAuthResult.WalletSelected)

println("Wallet address: ${result.walletAddress}")
Parameters
ParameterTypeDescription
idTokenStringOIDC ID token from the identity provider.
issuerStringExpected token issuer, such as https://accounts.google.com.
audienceStringExpected token audience.
walletSelectionWalletSelectionBehaviorDefaults to WalletSelectionBehavior.Automatic.
walletTypeWalletTypeOptional wallet type. Defaults to WalletType.Ethereum.
Returns Returns CompleteAuthResult.

Start OIDC Redirect Auth

Start an OIDC authorization-code PKCE flow and open the returned authorization URL in app-owned UI such as Custom Tabs.
import com.omsclient.kotlin_sdk.wallet.OidcProviders

val redirect = client.wallet.startOidcRedirectAuth(
    provider = OidcProviders.google(),
    redirectUri = "com.example.app:/auth/callback",
)

openCustomTab(redirect.authorizationUrl)
Parameters
ParameterTypeDescription
providerOidcProviderConfigOIDC provider configuration.
redirectUriStringApp callback URL that receives the provider redirect.
walletTypeWalletTypeOptional wallet type. Defaults to WalletType.Ethereum.
relayRedirectUriString?Optional OAuth redirect URI override.
authorizeParamsMap<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 from onCreate or onNewIntent for unrelated links.
import com.omsclient.kotlin_sdk.wallet.OidcRedirectAuthResult

when (val result = client.wallet.handleOidcRedirectCallback(intent.data?.toString())) {
    is OidcRedirectAuthResult.Completed -> {
        println("Wallet address: ${result.wallet.address}")
    }
    is OidcRedirectAuthResult.WalletSelection -> {
        result.pendingSelection.createAndSelectWallet()
    }
    OidcRedirectAuthResult.NotOidcRedirectCallback -> Unit
    OidcRedirectAuthResult.NoPendingAuth -> Unit
    is OidcRedirectAuthResult.Failed -> throw result.error
}
Parameters
ParameterTypeDescription
callbackUrlString?Incoming app-link URL.
walletSelectionWalletSelectionBehaviorDefaults to WalletSelectionBehavior.Automatic.
Returns Returns OidcRedirectAuthResult.

Use Wallet

Activate an existing wallet by server-side wallet ID.
client.wallet.useWallet(walletId = "wallet-id")
Parameters
ParameterTypeDescription
walletIdStringWallet ID returned by auth completion or listWallets().
Returns Returns WalletSelectionResult.

Create Wallet

Create and activate a new wallet for the authenticated user.
val result = client.wallet.createWallet(reference = "main")

println("New wallet: ${result.walletAddress}")
Parameters
ParameterTypeDescription
walletTypeWalletTypeWallet type to create. Defaults to WalletType.Ethereum.
referenceString?Optional app-defined wallet reference.
Returns Returns WalletSelectionResult.