BreafIO Team
Product & Engineering
How to Build a Crypto Wallet: Step-by-Step Developer Guide
Introduction
"Building a crypto wallet isn't just about rendering balances—it's about managing cryptographic key pairs, constructing safe transaction payloads, and interacting with distributed nodes."
Whether you're creating a non-custodial browser extension, a mobile Web3 wallet, or embedding wallet management into a SaaS platform, understanding the underlying cryptographic architecture is essential.
This step-by-step guide walks through building a custom non-custodial crypto wallet from key pair derivation to broadcasting transactions.
1. Understanding HD Wallets (BIP-39 & BIP-44)
Modern crypto wallets use Hierarchical Deterministic (HD) architecture. A single 12- or 24-word seed phrase (BIP-39) can generate an infinite tree of public/private key pairs across multiple blockchains.
BIP-39: Converts entropy into human-readable mnemonic seed phrases.
BIP-32 / BIP-44: Defines the standard derivation path for multi-account and multi-chain key generation:
m / purpose' / coin_type' / account' / change / address_index
(e.g., Ethereum uses m/44'/60'/0'/0/0)2. Core Architecture & Key Derivation (TypeScript)
Using core crypto libraries like ethers.js or @solana/web3.js, generating a new non-custodial wallet involves three key steps:
import { ethers } from "ethers";
// Step 1: Generate random entropy and mnemonic seed phrase
const mnemonic = ethers.Mnemonic.entropyToPhrase(ethers.randomBytes(16));
console.log("Seed Phrase:", mnemonic);
// Step 2: Derive HD Node from Mnemonic
const hdNode = ethers.HDNodeWallet.fromPhrase(mnemonic);
// Step 3: Derive first account wallet address
const userWallet = hdNode.derivePath("m/44'/60'/0'/0/0");
console.log("Public Address:", userWallet.address);
console.log("Private Key:", userWallet.privateKey);3. Signing & Broadcasting Transactions
A non-custodial wallet signs transactions locally before transmitting the raw bytecode to an RPC node provider (e.g., Alchemy, Infura, or QuickNode):
Construct Payload: Specify to, value, nonce, gasLimit, and max fee parameters (maxFeePerGas).
Local Cryptographic Signing: Sign the payload with the private key locally inside client memory. Never send private keys over the wire.
Broadcast: Use provider.broadcastTransaction(signedTx) to publish the transaction to the network mempool.
// Build transaction
const tx = {
to: "0xRecipientAddress",
value: ethers.parseEther("0.1"),
nonce: await provider.getTransactionCount(wallet.address),
gasLimit: 21000,
maxFeePerGas: ethers.parseUnits("20", "gwei"),
maxPriorityFeePerGas: ethers.parseUnits("2", "gwei"),
};
// Sign locally
const signedTx = await wallet.signTransaction(tx);
// Broadcast to network
const response = await provider.broadcastTransaction(signedTx);
console.log("Tx Hash:", response.hash);4. Multi-Chain Support
Extend your wallet to support multiple blockchains by adding chain-specific derivation paths and RPC configurations:
Ethereum: m/44'/60'/0'/0/0 (ETH, ERC-20 tokens)
Solana: m/44'/501'/0'/0' (SOL, SPL tokens)
Bitcoin: m/84'/0'/0'/0/0 (BTC, SegWit)
Use a chain registry configuration object to map chain IDs to RPC endpoints, block explorers, and native currency symbols.
5. Key Security Best Practices for Developers
Secure Storage: Store private keys or mnemonics in secure enclaves (iOS Keychain / Android Keystore) or encrypted memory—never in localStorage or unencrypted state.
RPC Redundancy: Fall back to secondary RPC endpoints if your primary provider experiences downtime or rate limits.
Account Abstraction (ERC-4337): Consider implementing smart contract wallets (paymasters, social recovery, and gasless transactions) to improve non-technical user onboarding.
Mnemonic Encryption: Encrypt the seed phrase with a user-derived key (PBKDF2 or Argon2) before storing it. The encryption key should never be stored alongside the encrypted data.
6. Testing Your Wallet
Test key generation with fixed entropy to verify deterministic derivation paths. Test transaction signing against known test vectors from EIP-155. Use Hardhat or Anvil for local forked network testing before deploying to mainnet.
Conclusion
Building a custom crypto wallet requires understanding cryptographic key management, HD wallet standards, and blockchain RPC interfaces. The foundation is BIP-39 mnemonic generation, BIP-44 derivation paths, and local transaction signing. From there, add multi-chain support, secure key storage, and account abstraction for production. The architectural patterns are well-established — the difference between a toy wallet and a production wallet is security rigor, not feature count.
Related Template
Try this production-ready starter kit to build your project faster.
Total Balance
$13,632
+2.4% today
ETH
2.45 ($8452)
MATIC
1250 ($875)
USDC
3200 ($3200)
ARB
850 ($1105)
Crypto Wallet
Send, receive, and manage crypto assets
Ready to Build?
Get started with our production-ready starter kits and ship your project faster.
Browse Starter Kits