TON DocsTON Docs
OnboardingNodesApplicationsAPIsSmart contractsTolkTolk languageTVMTON Virtual MachineFoundationsBlockchain foundations

How to manage TON wallets using WalletKit on the iOS platform

Initialize the WalletKit before managing wallets. See the initialization guide for details.

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:

  1. Create a signer: generate or import cryptographic keys
  2. Create an adapter: configure wallet version and network settings
  3. Add the wallet: register the wallet with the SDK

Creating wallets from mnemonic

Import an existing wallet from a mnemonic:

let mnemonic = TONMnemonic(value: ["word1", "word2", /* ... 24 words ... */])
let signer = try await walletKit.signer(mnemonic: mnemonic)
let adapter = try await walletKit.walletV5R1Adapter(
    signer: signer,
    parameters: .init(network: .mainnet)
)
let wallet = try await walletKit.add(walletAdapter: adapter)

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:

let privateKey = /* 32-byte private key as Data */
let signer = try await walletKit.signer(privateKey: privateKey)
let adapter = try await walletKit.walletV5R1Adapter(
    signer: signer,
    parameters: .init(network: .mainnet)
)
let wallet = try await walletKit.add(walletAdapter: adapter)

Wallet versions

The SDK supports multiple wallet contract versions: V5R1 and V4R2.

The latest wallet version with improved features and gas optimization:

let adapter = try await walletKit.walletV5R1Adapter(
    signer: signer,
    parameters: .init(network: .mainnet)
)

V4R2 (Compatible)

Widely supported legacy version:

let adapter = try await walletKit.walletV4R2Adapter(
    signer: signer,
    parameters: .init(network: .mainnet)
)

Retrieving wallets

Get all wallets managed by the SDK:

let wallets = try await walletKit.wallets()

Get a specific wallet by an address:

let wallet = try walletKit.wallet(address: "<TON_WALLET_ADDRESS>")

Removing wallets

Remove a single wallet:

try await walletKit.remove(walletAddress: "<TON_WALLET_ADDRESS>")

Next steps

On this page