> ## Documentation Index
> Fetch the complete documentation index at: https://docs.privacyboost.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Android SDK

> Native Kotlin SDK for privacy-preserving transactions on Android

# Android SDK

The Privacy Boost Android SDK is a native Kotlin library that wraps the Rust core via UniFFI. It exposes idiomatic Kotlin APIs (`suspend` functions, sealed classes, data classes) for shielding, unshielding, and private transfers.

## Features

* Native Kotlin library — no JavaScript bridge, no WebView
* `suspend` functions integrated with Kotlin coroutines
* `SdkException` sealed class — exhaustive `when` matching on error variants
* Optional default delegate implementations for Android Keystore and CredentialManager Passkey
* Wallet-agnostic — implement `WalletDelegate` once for any signer
* Identical core to the TypeScript / iOS / React Native SDKs (same proofs, same network protocol)

## Installation

Add the Maven artifact to your `build.gradle.kts`. See the [installation guide](./installation) for full details.

```kotlin theme={null}
dependencies {
    implementation("io.sunnyside:privacy-boost-android:0.2.0")
}
```

Then import:

```kotlin theme={null}
import com.privacyboost.sdk.PrivacyBoost
import com.privacyboost.sdk.PrivacyBoostConfig
import com.privacyboost.defaults.*  // optional delegate helpers
```

## Quick Example

```kotlin theme={null}
import com.privacyboost.sdk.*

val config = PrivacyBoostConfig(
    serverUrl = "https://optimism.sepolia.privacyboost.io",
    chainId = null,                  // discovered from server
    shieldContractAddress = null,    // discovered from server
    wethContractAddress = "0x4200000000000000000000000000000000000006",
    teePublicKey = null,
    appId = "app_abc123xyz",
    persistenceStorage = null,
    persistenceUnlock = null
)

val sdk = PrivacyBoost(config)

// Authenticate with a WalletDelegate you implement
val result = sdk.authenticate(
    wallet = myWalletDelegate,
    keySource = KeySource.WalletDerived(),
    tokenProvider = null
)

when (result) {
    is AuthResult.Authenticated -> {
        println("Privacy address: ${result.loginResult.privacyAddress}")
    }
    is AuthResult.CredentialRequired -> {
        // Prompt user for PIN/biometric, then call sdk.submitCredential(...)
    }
    is AuthResult.MnemonicGenerated -> {
        // First-time user — display mnemonic, then call sdk.proceedAfterMnemonic(...)
    }
    is AuthResult.RecoveryRequired -> {
        // Vault is in a recovery state — see Authentication concepts
    }
}

// Shield 1 ETH-equivalent of WETH
val amount = sdk.parseAmount("1.0", decimals = 18u)
val shielded = sdk.shield(
    tokenAddress = "0x4200000000000000000000000000000000000006",
    amount = amount
)
println("Shield tx: ${shielded.txHash}")
```

## Core Operations

| Method                                                    | Purpose                                |
| --------------------------------------------------------- | -------------------------------------- |
| `sdk.shield(tokenAddress, amount)`                        | Deposit tokens into the shielded pool  |
| `sdk.unshield(tokenAddress, amount, recipient)`           | Withdraw to a public address           |
| `sdk.send(tokenAddress, amount, recipientPrivacyAddress)` | Private transfer                       |
| `sdk.getBalance(tokenAddress)`                            | Single-token shielded + wallet balance |
| `sdk.getAllBalances()`                                    | All tracked balances                   |
| `sdk.getTransactionHistory(...)`                          | Paginated history                      |
| `sdk.resolveIdentity(identifier)`                         | Look up a privacy address              |

All operations are `suspend` functions — call them from a coroutine scope (`lifecycleScope`, `viewModelScope`, etc.).

## Documentation

### Getting Started

* [Installation](./installation)
* [Getting Started](./getting-started)

### Guides

* [Deposits](./guides/deposits)
* [Withdrawals](./guides/withdrawals)
* [Transfers](./guides/transfers)
* [Balances](./guides/balances)
* [Transactions](./guides/transactions)
* [Multi-Chain](./guides/multi-chain)
* [Wallet Integration](./guides/wallet-integration)
* [Session Storage](./guides/session-storage)
* [Error Handling](./guides/error-handling)

### Advanced

* [Performance](./advanced/performance)
* [Error Handling Patterns](./advanced/error-handling)

### Reference

* [API Reference](./api-reference)

## Requirements

* Android API 26+ (Android 8.0 Oreo)
* API 34+ (Android 14) required for Passkey delegate helpers
* Kotlin 1.9+
* AndroidX

## Related

* [Multi-Chain Concepts](/sdk/concepts/multi-chain) — architecture overview
* [Authentication Concepts](/sdk/concepts/authentication) — auth flow details
* [Quickstart](/sdk/quickstart/android) — 5-minute integration
