-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwallet-generate.js
executable file
·60 lines (50 loc) · 1.71 KB
/
wallet-generate.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
const fs = require('fs');
const { ethers } = require('ethers');
const bip39 = require('bip39');
// 连接到以太坊节点
const provider = new ethers.providers.StaticJsonRpcProvider('Provider_API');
// 生成助记词和私钥
function generateMnemonicAndPrivateKey() {
const mnemonic = bip39.generateMnemonic();
const wallet = ethers.Wallet.fromMnemonic(mnemonic);
const privateKey = wallet.privateKey;
return { mnemonic, privateKey };
}
// 生成以太坊地址
function generateEthAddress(privateKey) {
const wallet = new ethers.Wallet(privateKey, provider);
return wallet.address;
}
// 检查是否以 "888" 结尾
function endsWith888(input) {
return /88$/.test(input);
}
// 保存地址、助记词和私钥到文件
function saveToFile(data) {
fs.writeFile('output.txt', data.join('\n'), (err) => {
if (err) {
console.error('无法保存文件:', err);
return;
}
console.log('地址、助记词和私钥已保存到文件 output.txt');
});
}
// 生成靓号地址、助记词和私钥
function generateSpecialData(count) {
const specialData = [];
let i = 0;
while (specialData.length < count) {
const { mnemonic, privateKey } = generateMnemonicAndPrivateKey();
const address = generateEthAddress(privateKey);
if (endsWith888(address)) {
specialData.push(`Address: ${address}`, `Mnemonic: ${mnemonic}`, `Private Key: ${privateKey}`, '');
i++;
}
}
return specialData;
}
// 生成指定数量的靓号地址、助记词和私钥
const numberOfSpecialData = 10;
const specialData = generateSpecialData(numberOfSpecialData);
// 保存靓号地址、助记词和私钥到文件
saveToFile(specialData);