Introduction
Blockchain wallets fall into two primary categories: cold wallets and hot wallets. In simple terms, a cold wallet stores data locally, while a hot wallet relies on server-side storage. This guide explores cold wallet implementation, key functionalities, and best practices.
Key Tools & Libraries:
- bip39: Generates mnemonic phrases (seed phrases).
- ethereumjs-wallet: Creates, imports, and exports wallets.
- ethereumjs-tx: Signs transactions.
- ethereumjs-util: Integrates essential Ethereum functions.
- crypto-js: Provides encryption capabilities.
Core Concepts in Blockchain Wallets
Understanding these components is critical:
- Mnemonic Phrase: A human-readable backup for wallet recovery (e.g., "zoo zoo zoo ...").
- Private Key: A 256-bit number granting control over wallet funds.
- Public Address: Derived from the private key (e.g., 0x7F3a...).
- KeyStore File: Encrypted private key (requires a password).
Relationships:
- Mnemonic β Private Key (one-way derivation).
- Private Key β Public Address (one-way derivation).
- Password + Private Key β KeyStore (two-way encryption/decryption).
Wallet Functionalities
1. Creating a Wallet
Workflow:
- Generate a random mnemonic via
bip39. - Derive the private key using the mnemonic.
- Encrypt the private key with AES (using a user-defined password).
- Store encrypted data in
localStoragealongside wallet metadata.
π Learn more about secure key management
2. Importing a Wallet
Supported methods:
- Mnemonic: Regenerate the private key.
- KeyStore: Decrypt using the password.
- Private Key: Directly import (least secure).
3. Wallet Management
Security Note: Passwords cannot be retrieved; only reset.
Verification Process:
- Decrypt the stored encrypted private key using the input password.
- Compare the derived address with the original.
- If matched, proceed with operations (e.g., exporting keys).
4. Transactions & Receiving Funds
Sending ETH: Sign transactions via
ethereumjs-tx.- Gas Fees: Calculated as
gasPrice * gasLimit(1 ETH = 10βΉ Gwei).
- Gas Fees: Calculated as
- Receiving ETH: Share your public address or QR code.
π Optimize gas fees for transfers
FAQs
Q1: How secure are cold wallets?
Cold wallets are offline by design, minimizing exposure to hacks. Always back up mnemonics securely.
Q2: Can I recover a lost password?
No. Passwords encrypt KeyStore files; losing them means funds are permanently inaccessible.
Q3: Whatβs the difference between gasPrice and gasLimit?
- gasPrice: Fee per unit of gas (paid to miners).
- gasLimit: Max gas allocated per transaction.
Q4: Is sharing my public address safe?
Yes. Public addresses are for receiving funds only; private keys control outgoing transactions.
Best Practices
- Backup: Store mnemonics offline (e.g., hardware vaults).
- Encryption: Use AES-256 for local storage.
- Updates: Regularly audit dependencies like
ethereumjs-wallet.
For advanced wallet architectures, explore hierarchical deterministic (HD) wallets via BIP44 standards.