Skip to main content

Overview

The Kotlin SDK allows you to create and manage embedded wallets in your Android application. This includes creating wallets, deriving wallet accounts, and accessing wallet information. Before we start, ensure you’re familiar with the concepts of Wallets and Wallet Accounts.

Creating a wallet

After a user authenticates, you can create an embedded wallet for them using the createWallet function from the TurnkeyContext. You need to provide the wallet parameters, such as the wallet name and the accounts to derive. This example creates a wallet named “Wallet-<timestamp>” with both an Ethereum and a Solana account:
This wallet can then be accessed through the wallets property in the TurnkeyContext. This property is a StateFlow that updates whenever wallets are created or modified.
You can also manually refresh the list of wallets by calling the refreshWallets function from the TurnkeyContext:

Creating wallet accounts

You can specify which accounts to derive when creating a wallet using the accounts parameter in the createWallet function, as shown in the previous section. Each account is defined using the V1WalletAccountParams class, where you can set properties

V1WalletAccountParams

Configuration used to derive a single wallet account (curve + derivation path + address format).

After wallet creation

You can use the createWalletAccount function from the TurnkeyContext.client to add additional accounts to an existing wallet after it has been created.

Importing and exporting wallets

The Kotlin SDK lets you securely import/export wallets, accounts, and private keys using bundles you control, enabling backup, recovery, and migration.

Export

Wallets

Export a specified wallet and its accounts.
The Kotlin SDK wallet export will decrypt locally and return the secret to you (mnemonic).
To receive an encrypted ExportBundle instead, use the lower-level client method:

Wallet accounts

Export a specific wallet account.
The Kotlin SDK does currently provide helpers for exporting individual accounts. Use the lower-level client method:

Import

Imports take plaintext material (mnemonic or raw private key) and the SDK handles initialization and encryption behind the scenes.

Wallets

Imports a wallet from a mnemonic. Optionally pre-create accounts.

Next steps

Check out the Signing guide to learn how to sign transactions and messages with the embedded wallets you’ve created.