Method Signature
align.blockchain.wallets.encryptWallet(
wallet: Wallet,
password: string
): Promise<EncryptedWallet>
Parameters
The wallet object to encrypt
Password for encryption (use a strong password!)
Returns
The encrypted wallet data
The wallet’s public address (unencrypted)
Examples
import Align from "@tolbel/align";
import fs from "fs";
const align = new Align({
apiKey: process.env.ALIGN_API_KEY!,
environment: "sandbox",
});
// Create a wallet
const wallet = await align.blockchain.wallets.create();
console.log(`Created: ${wallet.address}`);
// Encrypt for secure storage
const encrypted = await align.blockchain.wallets.encryptWallet(
wallet,
"mySecurePassword123!"
);
// Save encrypted wallet
fs.writeFileSync(
`./wallets/${encrypted.address}.json`,
JSON.stringify(encrypted)
);
console.log("Wallet encrypted and saved!");
const wallet = await align.blockchain.wallets.create();
const encrypted = await align.blockchain.wallets.encryptWallet(
wallet,
password
);
console.log("Encrypted:", encrypted.address);
The public address is NOT encrypted - only the private key and mnemonic are
protected.