Kalium Private Wallet

Kalium Wallets come into existence through the utilization of an encryption key and a mnemonic. Following creation, these wallets are securely encrypted and stored within Kalium's database.

When generating wallets, it is imperative to employ either a 12- or 24-word mnemonic. To include a Kalium wallet in the local database, you have the option to either import an existing mnemonic or generate a fresh mnemonic using ethers.js.

Example: Generate mnemonic using ethers.js

import { Mnemonic, randomBytes } from 'ethers';

const mnemonic = Mnemonic.fromEntropy(randomBytes(16)).phrase.trim();

You may provide an optional creationBlockNumberMap which contains the block numbers for each chain when the wallet was created. This mapping will optimize private balance scans, especially for newly created wallets.

Example: Create local Kalium Wallet from mnemonic

import { createKaliumWallet } from '@kalium-community/wallet';
import { NetworkName } from '@kalium-community/shared-models';

const encryptionKey = ...; // See `Encryption Keys` section

const mnemonic = ...; // Either provided by user or generated with ethers.js

// Block numbers for each chain when wallet was first created.
// If unknown, provide undefined.
const creationBlockNumberMap: MapType<number> = {
    [NetworkName.Ethereum]: 15725700,
    [NetworkName.Polygon]: 3421400,
}

const kaliumWalletInfo = await createKaliumWallet(
    encryptionKey, 
    mnemonic, 
    creationBlockNumberMap,
);
const id = kaliumWalletInfo.id; // Store this value.

// kaliumWalletInfo contains other useful information, like the wallet's KALIUM address, i.e. '0zk987...654'

After first load, Kalium Wallets can be reloaded instantly using the loadWalletByID function. You will want to store the field kaliumWallet.id and reuse the encryptionKey in order to load it again. The kaliumWallet.id field will be used to reference the wallet when scanning balances, requesting transaction history, or creating new transactions.

Example: Load stored KALIUM Wallet from ID

import { loadWalletByID } from '@kalium-community/wallet';

const encryptionKey = ...; // See `Encryption Keys` section
const id = ...; // Previously stored when local Kalium wallet was created
const kaliumWalletInfo = await loadWalletByID(encryptionKey, id);

Last updated