Comprehensive breakdown of multi-chain crypto wallet implementation
Trust Wallet implements a non-custodial, multi-chain cryptocurrency wallet architecture that supports over 70+ blockchains including both EVM-compatible and non-EVM networks. The wallet leverages hierarchical deterministic (HD) wallet technology with military-grade encryption.
70+ blockchains supported
Users control private keys
Transparent & auditable
// EVM Network Configuration
const EVMNetworks = {
ethereum: {
chainId: 1,
rpc: "https://ethereum.publicnode.com",
explorer: "https://etherscan.io"
},
bsc: {
chainId: 56,
rpc: "https://bsc-dataseed.binance.org",
explorer: "https://bscscan.com"
},
polygon: {
chainId: 137,
rpc: "https://polygon-rpc.com",
explorer: "https://polygonscan.com"
}
}// Non-EVM Network Adapters
const NonEVMNetworks = {
bitcoin: {
addressType: "P2WPKH",
curve: "secp256k1",
derivation: "m/84'/0'/0'"
},
cosmos: {
addressPrefix: "cosmos",
curve: "secp256k1",
derivation: "m/44'/118'/0'/0"
},
solana: {
curve: "ed25519",
derivation: "m/44'/501'"
}
}// HD Wallet Implementation
class HDWallet {
constructor(entropy) {
// Generate seed from entropy
this.seed = pbkdf2(entropy, 'mnemonic', 2048, 64, 'sha512');
this.masterKey = hmacSha512('ed25519 seed', this.seed);
}
deriveKey(path) {
// BIP-44 derivation: m/44'/coin_type'/account'/change/index
return this.derivePath(path);
}
encrypt(privateKey, password) {
// AES-256-GCM encryption
const salt = crypto.randomBytes(32);
const key = scrypt(password, salt, 32);
const cipher = crypto.createCipher('aes-256-gcm', key);
return cipher.update(privateKey) + cipher.final();
}
}12/24-word BIP-39 mnemonic phrases derived from cryptographically secure entropy
entropy → mnemonic → seed → master_keyEncrypted local storage with multiple backup verification steps
encrypt(seed, user_password) → secure_storageCross-platform wallet restoration using seed phrase verification
mnemonic → validate → restore_wallet// WalletConnect v2 Implementation
class WalletConnectHandler {
async initializeSession(uri) {
const session = await this.client.connect({
uri,
requiredNamespaces: {
eip155: {
methods: ['eth_sendTransaction', 'personal_sign'],
chains: ['eip155:1', 'eip155:56'],
events: ['accountsChanged', 'chainChanged']
}
}
});
return session;
}
async signTransaction(request) {
// Validate request
const validated = await this.validateRequest(request);
// Show user confirmation UI
const approved = await this.requestUserApproval(validated);
if (approved) {
return await this.wallet.signTransaction(request.params);
}
throw new Error('User rejected request');
}
}Injected ethereum provider for seamless web3 interaction
Isolated execution environment with permission controls
Human-readable transaction summaries and risk analysis
Generate new wallet or import existing seed
Configure authentication and backup
Choose supported blockchain networks
Guided test transaction experience