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 is an Android library. It requires Android minSdk 26, Android compileSdk 34 or newer, Java 17 Android compile options, Kotlin, a project access key, and a project ID.

Install

Add the SDK dependency from Maven Central to your app module.
dependencies {
    implementation("io.github.0xsequence:oms-client-kotlin-sdk:0.1.0-alpha.1")
}
This is the only artifact consumers need. The generated wallet API client is packaged inside the AAR as an internal implementation detail.

Create The Client

Use the Android constructor to get secure session persistence and a non-extractable Android Keystore P-256 request credential.
import com.omsclient.kotlin_sdk.OMSClient

val client = OMSClient(
    context = context,
    publicApiKey = "YOUR_PROJECT_ACCESS_KEY",
    projectId = "YOUR_PROJECT_ID",
)
Create the client once for the app session. The client exposes:
PropertyUse
client.walletAuthentication, wallet selection, signing, signature verification, ID tokens, and transactions.
client.indexerToken balance reads.
client.sessionCompleted wallet-session state restored from Android-backed storage.
client.supportedNetworksNetworks supported by this SDK build.

Authenticate With Email

Email auth is a two-step OTP flow. Call these methods from a coroutine.
import com.omsclient.kotlin_sdk.wallet.CompleteAuthResult

if (client.wallet.walletAddress == null) {
    client.wallet.startEmailAuth("user@example.com")

    // Show your OTP input, then complete auth with the user-entered code.
    val result = client.wallet.completeEmailAuth("123456")
    check(result is CompleteAuthResult.WalletSelected)

    println("Wallet address: ${result.walletAddress}")
}
completeEmailAuth resolves the authenticated wallet. If one matching wallet exists, it uses it. If none exists, it creates one.

Send A Transaction

After authentication, send a native token transaction with client.wallet.sendTransaction. Values are raw base-unit integers. On testnets, fee options are automatically sponsored, so Polygon Amoy is a good first network for testing.
import com.omsclient.kotlin_sdk.Network
import java.math.BigInteger

val tx = client.wallet.sendTransaction(
    network = Network.AMOY,
    to = "0xRecipient",
    value = BigInteger.ZERO,
)

println("Transaction id: ${tx.txnId}")
println("Transaction hash: ${tx.txnHash}")