Skip to main content
This example shows how to generate multiple wallet addresses from a single mnemonic by changing the subwallet_id in the wallet config. Each subwallet_id produces a unique address under the same seed phrase.

Example

Explanation

  • subwallet_id — a 32-bit integer used to derive distinct wallet addresses from the same mnemonic. It is part of the wallet config (WalletV3Config, WalletV4Config, etc. from ton_core), passed to .from_mnemonic() / .from_private_key() / .create() via the config= argument.
  • Use cases:
    • Splitting funds across logical accounts.
    • Managing separate balances.
    • Creating derived wallets for contract operations.

Important Notes

  • subwallet_id is not supported in:
    • WalletV1*
    • WalletV2*
    • WalletPreprocessedV2
  • Default value: for all wallet types with an integer subwallet_id (WalletV3*, WalletV4*, WalletHighloadV2, WalletHighloadV3R1) the default is 698983191 (DEFAULT_SUBWALLET_ID from ton_core).
  • WalletV5R1 and WalletV5Beta use a structured identifier instead of a plain integer: WalletV5SubwalletID from ton_core, with fields subwallet_number (default 0), workchain (WorkchainID, default basechain), version (default 0), and network (NetworkGlobalID, default mainnet). If subwallet_id is left unset in the config, the library fills it in using the client’s network. WalletV5R1 packs the fields into a 32-bit integer XORed with the network global ID; WalletV5Beta stores the four fields separately in the wallet data:
    Default packed values (WalletV5R1):