-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
38 lines (27 loc) · 944 Bytes
/
index.js
File metadata and controls
38 lines (27 loc) · 944 Bytes
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
import { words } from './wordList.js';
import { ethers } from "ethers";
const provider = new ethers.getDefaultProvider("homestead", {
etherscan: process.env.API_KEY
});
function genSeedPhrase() {
let seedPhrase = []
for (let i = 0; i < 12; i++){
let number = Math.floor(Math.random() * 2048);
seedPhrase.push(words[number]);
}
return seedPhrase.join(' ');
}
async function main(){
let phrase = genSeedPhrase();
let result = ethers.utils.isValidMnemonic(phrase);
if(result === true) {
let walletMnemonic = ethers.Wallet.fromMnemonic(phrase);
let wallet = walletMnemonic.connect(provider)
let balance = await wallet.getBalance();
console.log(`Valid Seed Phrase:\n${phrase}`)
console.log("Address: " + wallet.address + "\nBalance: " + balance + " ETH\n\n");
if(balance > 0) return;
return main();
} else return main();
}
main();