-
Notifications
You must be signed in to change notification settings - Fork 156
/
index.js
executable file
·62 lines (56 loc) · 1.42 KB
/
index.js
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env node
const ethers = require('ethers');
const yargs = require('yargs');
const options = yargs
.usage("Usage: -m <mnemonic>")
.option("m", {
alias: "mnemonic",
describe: "BIP39 Mnemonic seed phrase",
type: "array",
demandOption: true,
})
.option("l", {
alias: "language",
describe: "Wordlist language used for mnemonic",
type: "String",
})
.argv;
var wordlist;
switch(options.language) {
case "english":
wordlist = ethers.wordlists.en;
break;
case "spanish":
wordlist = ethers.wordlists.es;
break;
case "french":
wordlist = ethers.wordlists.fr;
break;
case "italian":
wordlist = ethers.wordlists.it;
break;
case "czech":
wordlist = ethers.wordlists.cz;
break;
case "japanese":
wordlist = ethers.wordlists.ja;
break;
case "korean":
wordlist = ethers.wordlists.ko;
break;
case "chinese_simplified":
wordlist = ethers.wordlists.zh_cn;
break;
case "chinese_traditional":
wordlist = ethers.wordlists.zh_tw;
break;
// TODO Missing czech, french, spanish
default:
wordlist = ethers.wordlists.en;
}
const account = ethers.Wallet.fromMnemonic(
options.mnemonic.join(" "),
"m/44'/60'/0'/0/0", // path (default)
wordlist,
);
console.log(account.address);