-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
45 lines (37 loc) · 1.12 KB
/
main.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
const fs = require('fs');
const { ethers } = require('ethers');
function generateWallet() {
let walletInfo;
do {
const wallet = ethers.Wallet.createRandom(['123456789qwerty']);
walletInfo = {
mnemonic: wallet.mnemonic.phrase,
privateKey: wallet.privateKey,
address: wallet.address,
};
} while (!GetZero(walletInfo.address));
return walletInfo;
}
function GetZero(address) {
// get 6 landing zero 0x000000
return /^0x0{6}/.test(address);
}
let walletInfo;
let count = 0;
do {
walletInfo = generateWallet();
count++;
} while (!GetZero(walletInfo.address));
console.log(`\nWallet looping count ${count} :`);
console.log('Seed phrase (Mnemonic):', walletInfo.mnemonic);
console.log('Private Key:', walletInfo.privateKey);
console.log('Address:', walletInfo.address);
// save file
const filename = 'address.txt';
const content = `Seed phrase (Mnemonic): ${walletInfo.mnemonic}\nPrivate Key: ${walletInfo.privateKey}\nAddress: ${walletInfo.address}\n`;
try {
fs.appendFileSync(filename, content);
console.log(`Saved file ${filename}`);
} catch (err) {
console.error('failed save file:', err);
}