-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgenerate-wallets.js
41 lines (36 loc) · 1.18 KB
/
generate-wallets.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
const fs = require('fs');
const Web3 = require("web3");
const WALLET_NUM = 200000;
const BATCH_NUM = 5000;
const WHITELIST_FILE = "whitelist.txt";
function getWeb3() {
var web3 = new Web3('https://data-seed-prebsc-2-s1.binance.org:8545');
return web3;
}
function appendFile(filepath, lines) {
let fd = fs.openSync(filepath, "a");
lines.forEach(line => {
fs.writeSync(fd, (line + "\n"));
});
fs.closeSync(fd);
}
function generateWallets() {
let web3 = getWeb3();
let batch = BATCH_NUM;
let startTime = Date.now();
let addresses = [];
for (let idx=0; idx<WALLET_NUM; idx++) {
let account = web3.eth.accounts.create();
addresses.push(account.address);
if (addresses.length>=batch) {
appendFile(WHITELIST_FILE, addresses);
addresses = [];
console.log(`Generated ${idx+1}/${WALLET_NUM} addresses in ${((Date.now() - startTime)/(60*1000)).toFixed(2)} mins...`);
}
}
if (addresses.length>0) {
console.log(`Generated ${WALLET_NUM}/${WALLET_NUM} addresses in ${((Date.now() - startTime)/(60*1000)).toFixed(2)} mins...`);
}
console.log("DONE!!!");
}
generateWallets();