-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
70 lines (62 loc) · 1.89 KB
/
index.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
const { Wallet, utils, providers, Contract } = require("ethers");
const { shuffle } = require("lodash");
const fs = require("fs");
const WORDS = require("./words.json");
const multicallArtifact = require("./abi/multicall.json");
const { formatEther } = require("ethers/lib/utils");
const PROVIDER = new providers.JsonRpcProvider(
"https://mainnet.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161"
);
const MULTICALL = new Contract(
"0x5BA1e12693Dc8F9c48aAD8770482f4739bEeD696",
multicallArtifact.abi,
PROVIDER
);
const run = async () => {
let chunks = [];
let words = WORDS;
while (true) {
try {
words = shuffle(words);
const mnemonic = words.slice(0, 12).join(" ");
if (utils.isValidMnemonic(mnemonic)) {
const wallet = Wallet.fromMnemonic(mnemonic);
if (chunks.length < 2000) {
chunks.push({
mnemonic,
address: wallet.address,
});
} else {
const request = chunks.map((chunk) => ({
target: "0x5BA1e12693Dc8F9c48aAD8770482f4739bEeD696",
callData: MULTICALL.interface.encodeFunctionData("getEthBalance", [
chunk.address,
]),
}));
const [, multicallResult] = await MULTICALL.aggregate(request);
multicallResult.forEach((result, index) => {
const balance = parseFloat(
formatEther(
MULTICALL.interface.decodeFunctionResult(
"getEthBalance",
result
)[0]
)
);
if (balance > 0) {
console.log(chunks[index].mnemonic);
fs.writeFileSync(
`./data/${chunks[index].address}`,
JSON.stringify(chunks[index])
);
}
});
chunks = [];
}
}
} catch (err) {
console.log(err);
}
}
};
run();