The SDK provides a comprehensive API for creating, retrieving, and managing wallets. All wallet operations follow a three-step pattern.
Creation pattern
The SDK uses a three-step pattern for creating wallets, providing fine-grained control over key management and wallet configuration:
- Create a signer: generate or import cryptographic keys
- Create an adapter: configure wallet version and network settings
- Add the wallet: register the wallet with the SDK
Creating wallets from mnemonic
Import an existing wallet from a mnemonic:
val mnemonic = listOf("word1", "word2", /* ... 24 words ... */)
val signer = walletKit.createSignerFromMnemonic(mnemonic)
val adapter = walletKit.createV5R1Adapter(
signer = signer,
network = TONNetwork.MAINNET
)
val wallet = walletKit.addWallet(adapter.adapterId)
Always store mnemonic phrases securely using platform-specific encrypted storage. Never store them in plain text or as part of the code.
Creating wallets from secret key
For externally managed keys:
val secretKey = /* 32-byte secret key as ByteArray */
val signer = walletKit.createSignerFromSecretKey(secretKey)
val adapter = walletKit.createV5R1Adapter(
signer = signer,
network = TONNetwork.MAINNET
)
val wallet = walletKit.addWallet(adapter.adapterId)
Wallet versions
The SDK supports multiple wallet contract versions: V5R1 and V4R2.
V5R1 (Recommended)
The latest wallet version with improved features and gas optimization:
val adapter = walletKit.createV5R1Adapter(
signer = signer,
network = TONNetwork.MAINNET
)
V4R2 (Compatible)
Widely supported legacy version:
val adapter = walletKit.createV4R2Adapter(
signer = signer,
network = TONNetwork.MAINNET
)
Retrieving wallets
Get all wallets managed by the SDK:
val wallets = walletKit.getWallets()
Get a specific wallet by an address:
val wallet = walletKit.getWallet("<TON_WALLET_ADDRESS>")
Removing wallets
Remove a single wallet:
walletKit.removeWallet("<TON_WALLET_ADDRESS>")
Next steps