-
Notifications
You must be signed in to change notification settings - Fork 1
/
mnemonic.ts
27 lines (22 loc) · 953 Bytes
/
mnemonic.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { task } from "hardhat/config";
import _ from "lodash";
import * as _path from "path";
import { deriveAccounts, defaultMnemonic, defaultDerivationPath } from "../helpers";
import "../type-extensions";
export const TASK_MNEMONIC = "mnemonic";
task(TASK_MNEMONIC, "Derive accounts from BIP-39 mnemonic")
.addPositionalParam("words", "Mnemonic words", defaultMnemonic)
.addOptionalParam("path", "Derivation path", defaultDerivationPath)
.addOptionalParam("count", "Number of accounts to derive", "10")
.setAction(async (taskArgs) => {
const { words, path, count } = taskArgs;
const wallets = deriveAccounts({
mnemonic: words,
path: path,
count: parseInt(count),
});
console.log(" address private key");
_.forEach(wallets, (wallet, idx) => {
console.log(idx.toString().padStart(3, ' '), wallet.address, _.trimStart(wallet.privateKey, "0x"));
});
});