forked from eth-collision/eth-collision-random
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnumbers.js
94 lines (86 loc) · 2.43 KB
/
numbers.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
const { ethers } = require("ethers");
const axios = require("axios");
const fs = require("fs");
const { apiKey, tgKey, tgChatId } = require("./config.js");
let fileSuffix = "numbers";
let yesFilename = `yes-${fileSuffix}.txt`;
let noFilename = `no-${fileSuffix}.txt`;
let errFilename = `err-${fileSuffix}.txt`;
function getAddress(privateKey) {
let wallet = new ethers.Wallet(privateKey);
return [privateKey, wallet.address];
}
function getBalanceMultiAddr(priKey, address) {
url = `https://api.etherscan.io/api?module=account&action=balancemulti&address=${address}&tag=latest&apikey=${apiKey}`;
axios
.get(url)
.then((res) => {
if (res.data.status == "1") {
for (let i = 0; i < res.data.result.length; i++) {
let data = res.data.result[i];
let account = data["account"];
let balance = data["balance"];
if (balance == "0") {
writeFile(priKey[i], account, balance, noFilename);
} else {
writeFile(priKey[i], account, balance, yesFilename);
}
}
}
if (res.data.status == "0") {
writeFile(priKey, address, res.data.result, errFilename);
}
})
.catch((err) => console.log(err));
}
function writeFile(priKey, address, balance, filename) {
data = `${priKey},${address},${balance}\n`;
fs.appendFile(filename, data, function (err) {
if (err) console.log(err);
console.log(`Saved: ${address}`);
});
}
function execOnceMultiAddr(keys, addrs) {
for (let i = 0; i < addrs.length; i += 20) {
let k = [];
let s = "";
for (let j = i; j < i + 20 && j < addrs.length; j++) {
k.push(keys[j]);
s += addrs[j] + ",";
}
s = s.slice(0, -1);
getBalanceMultiAddr(k, s);
}
}
function getAddrs(priKeys) {
let keys = [];
let addrs = [];
for (let i = 0; i < priKeys.length; i++) {
let [k, v] = getAddress(priKeys[i]);
keys.push(k);
addrs.push(v);
}
execOnceMultiAddr(keys, addrs);
}
async function sleep(millis) {
return new Promise((resolve) => setTimeout(resolve, millis));
}
async function numbers() {
for (let i = 1; i < 2000000; i += 20) {
let arr = [];
for (let j = i; j < i + 20; j++) {
console.log(j);
let hex = "0x";
let s = j.toString(16);
for (let k = 0; k < 64 - s.length; k++) {
hex += "0";
}
hex += s;
arr.push(hex);
}
// console.log(arr)
getAddrs(arr);
await sleep(1000);
}
}
numbers();