-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathindex.js
More file actions
303 lines (254 loc) · 10.2 KB
/
index.js
File metadata and controls
303 lines (254 loc) · 10.2 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
const axios = require('axios');
const { ethers } = require('ethers');
const readline = require('readline');
require('dotenv').config();
const colors = {
reset: "\x1b[0m",
cyan: "\x1b[36m",
green: "\x1b[32m",
yellow: "\x1b[33m",
red: "\x1b[31m",
white: "\x1b[37m",
bold: "\x1b[1m"
};
const logger = {
info: (msg) => console.log(`${colors.green}[✓] ${msg}${colors.reset}`),
warn: (msg) => console.log(`${colors.yellow}[⚠] ${msg}${colors.reset}`),
error: (msg) => console.log(`${colors.red}[✗] ${msg}${colors.reset}`),
success: (msg) => console.log(`${colors.green}[✅] ${msg}${colors.reset}`),
loading: (msg) => console.log(`${colors.cyan}[⟳] ${msg}${colors.reset}`),
step: (msg) => console.log(`${colors.white}[➤] ${msg}${colors.reset}`),
userInfo: (msg) => console.log(`${colors.white}[✓] ${msg}${colors.reset}`),
banner: () => {
console.log(`${colors.cyan}${colors.bold}`);
console.log(`---------------------------------------------`);
console.log(` TurnKey Auto Bot - Airdrop Insiders `);
console.log(`---------------------------------------------${colors.reset}`);
console.log();
}
};
const getRandomUA = () => {
const userAgents = [
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:121.0) Gecko/20100101 Firefox/121.0'
];
return userAgents[Math.floor(Math.random() * userAgents.length)];
};
const RPC_URL = 'https://ethereum-sepolia-rpc.publicnode.com';
const CHAIN_ID = 11155111;
const EXPLORER_URL = 'https://sepolia.etherscan.io';
const network = {
name: 'sepolia',
chainId: CHAIN_ID,
ensAddress: null
};
const provider = new ethers.JsonRpcProvider(RPC_URL, network);
class ETHSepoliaBot {
constructor() {
this.privateKeys = [];
this.wallets = [];
this.txCount = 0;
this.config = {};
this.minAmount = 0.000001;
this.maxAmount = 0.0000022;
}
generateRandomAmount() {
const randomAmount = Math.random() * (this.maxAmount - this.minAmount) + this.minAmount;
return parseFloat(randomAmount.toFixed(8));
}
loadPrivateKeys() {
logger.loading('Loading private keys from environment...');
let keyIndex = 1;
while (true) {
const key = process.env[`PRIVATE_KEY_${keyIndex}`];
if (!key) break;
try {
const wallet = new ethers.Wallet(key, provider);
this.privateKeys.push(key);
this.wallets.push(wallet);
keyIndex++;
} catch (error) {
logger.error(`Invalid private key format for PRIVATE_KEY_${keyIndex}`);
keyIndex++;
}
}
if (this.privateKeys.length === 0) {
logger.error('No valid private keys found in environment variables!');
process.exit(1);
}
logger.success(`Loaded ${this.privateKeys.length} private keys`);
}
async displayUserInfo() {
logger.step('Fetching wallet information...');
logger.info(`Network: Sepolia Testnet (Chain ID: ${CHAIN_ID})`);
logger.info(`RPC: ${RPC_URL}`);
logger.info(`Explorer: ${EXPLORER_URL}`);
logger.info(`Random Amount Range: ${this.minAmount} - ${this.maxAmount} ETH`);
console.log();
for (let i = 0; i < this.wallets.length; i++) {
const wallet = this.wallets[i];
try {
const balance = await provider.getBalance(wallet.address);
const balanceInEth = ethers.formatEther(balance);
logger.userInfo(`Wallet ${i + 1}:`);
logger.userInfo(` Address: ${wallet.address}`);
logger.userInfo(` Balance: ${balanceInEth} ETH`);
logger.userInfo(` Explorer: ${EXPLORER_URL}/address/${wallet.address}`);
console.log();
} catch (error) {
logger.error(`Failed to fetch balance for wallet ${i + 1}: ${error.message}`);
await new Promise(resolve => setTimeout(resolve, 2000));
try {
const balance = await provider.getBalance(wallet.address);
const balanceInEth = ethers.formatEther(balance);
logger.userInfo(`Wallet ${i + 1} (retry):`);
logger.userInfo(` Address: ${wallet.address}`);
logger.userInfo(` Balance: ${balanceInEth} ETH`);
console.log();
} catch (retryError) {
logger.error(`Retry failed for wallet ${i + 1}: ${retryError.message}`);
}
}
}
}
generateRandomAddress() {
return ethers.Wallet.createRandom().address;
}
async getUserInput() {
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
return new Promise((resolve) => {
rl.question(`${colors.yellow}Enter number of transactions per wallet: ${colors.reset}`, (txCount) => {
rl.close();
resolve({
txCount: parseInt(txCount)
});
});
});
}
async sendTransaction(wallet, toAddress) {
try {
const randomAmount = this.generateRandomAmount();
const nonce = await provider.getTransactionCount(wallet.address);
const feeData = await provider.getFeeData();
const tx = {
to: toAddress,
value: ethers.parseEther(randomAmount.toString()),
gasLimit: 21000,
maxFeePerGas: feeData.maxFeePerGas,
maxPriorityFeePerGas: feeData.maxPriorityFeePerGas,
nonce: nonce,
chainId: CHAIN_ID,
type: 2
};
logger.loading(`Sending ${randomAmount} ETH from ${wallet.address} to ${toAddress}...`);
const txResponse = await wallet.sendTransaction(tx);
logger.success(`Transaction sent! Hash: ${txResponse.hash}`);
logger.info(`Amount: ${randomAmount} ETH`);
logger.info(`Explorer: ${EXPLORER_URL}/tx/${txResponse.hash}`);
const receipt = await txResponse.wait();
logger.success(`Transaction confirmed in block ${receipt.blockNumber}`);
return { success: true, hash: txResponse.hash, amount: randomAmount };
} catch (error) {
logger.error(`Transaction failed: ${error.message}`);
return { success: false, error: error.message };
}
}
async executeDailyTransactions() {
logger.step(`Starting daily transaction batch...`);
logger.info(`Amount range: ${this.minAmount} - ${this.maxAmount} ETH (random)`);
logger.info(`Transactions per wallet: ${this.config.txCount}`);
logger.info(`Total wallets: ${this.wallets.length}`);
console.log();
let totalSuccess = 0;
let totalFailed = 0;
let totalAmountSent = 0;
for (let i = 0; i < this.wallets.length; i++) {
const wallet = this.wallets[i];
logger.step(`Processing wallet ${i + 1}/${this.wallets.length} (${wallet.address})`);
for (let j = 0; j < this.config.txCount; j++) {
const randomAddress = this.generateRandomAddress();
const result = await this.sendTransaction(wallet, randomAddress);
if (result.success) {
totalSuccess++;
totalAmountSent += result.amount;
} else {
totalFailed++;
}
const delay = Math.random() * 2000 + 1000;
await new Promise(resolve => setTimeout(resolve, delay));
}
if (i < this.wallets.length - 1) {
const walletDelay = Math.random() * 2000 + 3000;
await new Promise(resolve => setTimeout(resolve, walletDelay));
}
}
logger.success(`Daily batch completed!`);
logger.info(`Successful transactions: ${totalSuccess}`);
logger.info(`Failed transactions: ${totalFailed}`);
logger.info(`Total amount sent: ${totalAmountSent.toFixed(8)} ETH`);
console.log();
}
async countdown(hours = 24) {
const totalSeconds = hours * 60 * 60;
for (let i = totalSeconds; i > 0; i--) {
const hours = Math.floor(i / 3600);
const minutes = Math.floor((i % 3600) / 60);
const seconds = i % 60;
const timeString = `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
process.stdout.write(`\r${colors.cyan}[⏰] Next execution in: ${timeString}${colors.reset}`);
await new Promise(resolve => setTimeout(resolve, 1000));
}
console.log();
logger.success('Time\'s up! Starting next batch...');
}
async run() {
logger.banner();
logger.loading('Testing RPC connection...');
try {
const blockNumber = await provider.getBlockNumber();
logger.success(`Connected to Sepolia! Latest block: ${blockNumber}`);
} catch (error) {
logger.error(`RPC connection failed: ${error.message}`);
logger.error('Please check your internet connection and try again.');
process.exit(1);
}
this.loadPrivateKeys();
await this.displayUserInfo();
const userConfig = await this.getUserInput();
this.config = userConfig;
logger.success(`Configuration saved:`);
logger.info(`Amount range: ${this.minAmount} - ${this.maxAmount} ETH (random)`);
logger.info(`Transactions per wallet: ${this.config.txCount}`);
console.log();
while (true) {
try {
await this.executeDailyTransactions();
await this.countdown(24);
} catch (error) {
logger.error(`Error in main loop: ${error.message}`);
logger.warn('Retrying in 5 minutes...');
await new Promise(resolve => setTimeout(resolve, 300000));
}
}
}
}
process.on('SIGINT', () => {
console.log();
logger.warn('Bot stopped by user');
process.exit(0);
});
process.on('uncaughtException', (error) => {
logger.error(`Uncaught exception: ${error.message}`);
process.exit(1);
});
const bot = new ETHSepoliaBot();
bot.run().catch(error => {
logger.error(`Bot failed to start: ${error.message}`);
process.exit(1);
});