The Hierarchical Deterministic (HD) key creation and transfer protocol (BIP32), allows creating child keys from parent keys in a hierarchy. Wallets using the HD protocol are called HD wallets.
When using such a wallet for development of Ethereum Smart Contracts, it is often necessary to test code using multiple accounts to simulate different users. In such situations, HDWalletAccounts can be used to quickly get an array of accounts and their corresponding public and private keys.
$ npm install hdwallet-accounts
let HDWalletAccounts = ;// 12 word mnemoniclet mnemonic = "myth slice august trophy letter display elephant accuse absorb enjoy hawk course";// Generate 10 accounts using the mnemoniclet walletAccounts = ;// Or, alternatively skip the mnemonic and have one auto-createdlet walletAccounts = ;console;console;console;console;
number. Number of accounts to generate. Defaults to 10.
string. 12-word mnemonic from which accounts are created. Auto-generated if not specified.
You can easily use this within a Truffle configuration. In fact, this package was created to make Ganache accounts available in Truffle test scripts.
let HDWalletAccounts = ;let walletAccounts = ;