forked from stepanbux/zora_checker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchecker.js
More file actions
77 lines (64 loc) · 2.25 KB
/
checker.js
File metadata and controls
77 lines (64 loc) · 2.25 KB
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
const fs = require('fs');
const path = require('path');
console.log(`
_ _ _ _ _ _____ _
| | | (_) | | | | / ____| | |
| |__| |_ __| | __| | ___ _ __ | | ___ __| | ___
| __ | |/ _\` |/ _\` |/ _ \\ '_ \\| | / _ \\ / _\` |/ _ \\
| | | | | (_| | (_| | __/ | | | |___| (_) | (_| | __/
|_| |_|_|\\__,_|\\__,_|\\___|_| |_|\\_____\\___/ \\__,_|\\___|
Zora Checker by stepanBD
https://t.me/hidden_coding
`);
let totalTokensSum = 0;
let completedRequests = 0;
let totalWallets = 0;
const fetchWallet = (wallet, tries = 0) => {
fetch('https://zora-checker.vercel.app/api/check-allocation', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: JSON.stringify({ walletAddress: wallet })
})
.then(response => {
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
return response.json();
})
.then(data => {
console.log(`Wallet: ${wallet}, tokens: ${data.totalTokens}`);
totalTokensSum += data.totalTokens;
completedRequests++;
checkIfAllDone();
})
.catch(error => {
console.error(`Error request, repeating... (${tries + 1}/3)`, error);
if (tries + 1 < 3) {
setTimeout(() => fetchWallet(wallet, tries + 1), 1000);
} else {
completedRequests++;
checkIfAllDone();
}
});
}
const checkIfAllDone = () => {
if (completedRequests === totalWallets) {
console.log(`\n✅ Total Tokens across all wallets: ${totalTokensSum}`);
}
}
const checkWallets = (wallets) => {
totalWallets = wallets.length;
wallets.forEach((wallet, index) => {
setTimeout(() => fetchWallet(wallet), 3000 * index);
});
}
const filePath = path.join(__dirname, 'wallets.txt');
fs.readFile(filePath, 'utf8', (err, data) => {
if (err) {
console.error('Ошибка чтения файла:', err);
return;
}
const wallets = data.split('\n').map(line => line.trim()).filter(line => line.length > 0);
checkWallets(wallets);
});