-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathautotxv.js
146 lines (121 loc) · 4.15 KB
/
autotxv.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
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
import { ethers } from "ethers";
import cfonts from "cfonts";
import readline from "readline";
import dotenv from "dotenv";
// Load environment variables from .env file
dotenv.config();
// Configuration
const RPC_URL = "https://rpc-testnet.inichain.com";
const PRIVATE_KEY = process.env.PRIVATE_KEY; // Load private key from .env
const LOOP_INTERVAL = 1 * 60 * 1000; // 1 minute in milliseconds
// Validate private key
if (!PRIVATE_KEY) {
console.error("\x1b[31mError: PRIVATE_KEY is not set in the .env file.\x1b[0m");
process.exit(1);
}
// Initialize provider and wallet
const provider = new ethers.JsonRpcProvider(RPC_URL);
const wallet = new ethers.Wallet(PRIVATE_KEY, provider);
// Styled log helper
function styledLog(message, color = "\x1b[36m") {
console.log(`${color}%s\x1b[0m`, message);
}
// Generate a random address
function getRandomAddress() {
return ethers.Wallet.createRandom().address;
}
// CLI prompt helper
function promptQuestion(query) {
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
return new Promise((resolve) => rl.question(query, (answer) => {
rl.close();
resolve(answer);
}));
}
// Send ether with nonce increment
async function sendEther(toAddress, amount, gasPrice, nonce) {
try {
styledLog(`Sending ether to: ${toAddress}`, "\x1b[32m");
// Create transaction
styledLog("\nSending transaction...");
const tx = await wallet.sendTransaction({
to: toAddress,
value: ethers.parseEther(amount),
gasPrice: ethers.parseUnits(gasPrice, "gwei"),
nonce, // Use the specified nonce
});
styledLog(`Transaction sent! Hash: ${tx.hash}`, "\x1b[36m");
// Wait for confirmation
styledLog("\nWaiting for confirmation...\n");
const receipt = await tx; // Wait for at least 1 block confirmation
if (receipt) {
styledLog("\u2705 Transaction Confirmed!", "\x1b[32m");
} else {
styledLog("\u274c Transaction not yet confirmed", "\x1b[31m");
}
} catch (error) {
console.error("\x1b[31mError sending ether:\x1b[0m", error.message);
}
}
// Main process
async function main() {
cfonts.say("NT Exhaust", {
font: "block",
align: "center",
colors: ["cyan", "magenta"],
background: "black",
letterSpacing: 1,
lineHeight: 1,
space: true,
maxLength: "0",
});
styledLog("=== Telegram Channel : NT Exhaust (@NTExhaust) ===", "\x1b[36m");
const choice = await promptQuestion(
"Choose an option:\n1. Send to random addresses\n2. Send to specific addresses\nEnter your choice (1 or 2): "
);
let recipients = [];
const isRandomAddress = choice === "1";
if (isRandomAddress) {
styledLog("Selected: Random Addresses", "\x1b[33m");
} else if (choice === "2") {
const addressList = await promptQuestion(
"Enter the recipient addresses (comma-separated): "
);
recipients = addressList.split(",").map((addr) => addr.trim());
styledLog(`Selected Specific Addresses: ${recipients.join(", ")}`, "\x1b[33m");
} else {
console.log("Invalid choice. Exiting...");
return;
}
const amount = await promptQuestion("Enter the amount of INI to send: ");
const gasPrice = await promptQuestion(
"Enter the gas price in Gwei (e.g., 20): "
);
const loopCount = parseInt(
await promptQuestion("Enter how many times to repeat (loop count): "),
10
);
// Fetch the starting nonce
let currentNonce = await provider.getTransactionCount(wallet.address);
for (let i = 0; i < loopCount; i++) {
styledLog(`\n[Loop ${i + 1}/${loopCount}]`, "\x1b[35m");
if (isRandomAddress) {
recipients = [getRandomAddress()];
styledLog(`Generated random address: ${recipients[0]}`, "\x1b[34m");
}
for (const recipient of recipients) {
await sendEther(recipient, amount, gasPrice, currentNonce);
currentNonce++; // Increment nonce after each transaction
}
if (i < loopCount - 1) {
styledLog(`Waiting for 1 minute before the next transaction...`, "\x1b[33m");
await new Promise((resolve) => setTimeout(resolve, LOOP_INTERVAL));
}
}
styledLog("\nAll tasks completed! Exiting script.", "\x1b[32m");
}
// Run the script
main();