-
Notifications
You must be signed in to change notification settings - Fork 11
/
spn.js
62 lines (49 loc) · 2.08 KB
/
spn.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
const readline = require('readline');
const Web3 = require('web3');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.question('Enter your private key: ', (privateKey) => {
rl.question('Enter recipient\'s address: ', (toAddress) => {
rl.question('Enter range of amounts to transfer (e.g., 0.00001,0.0002): ', (amountRange) => {
rl.question('Enter range of intervals in seconds (e.g., 10,15): ', (intervalRange) => {
const [minAmount, maxAmount] = amountRange.split(',').map(Number);
const [minInterval, maxInterval] = intervalRange.split(',').map(Number);
const rpcURL = "https://testnet-rpc.superposition.so/";
const web3 = new Web3(new Web3.providers.HttpProvider(rpcURL));
function getRandomAmount(min, max) {
return (Math.random() * (max - min) + min).toFixed(2);
}
function getRandomInterval(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
}
function sendTransaction() {
const amount = getRandomAmount(minAmount, maxAmount);
const interval = getRandomInterval(minInterval, maxInterval);
const account = web3.eth.accounts.privateKeyToAccount(privateKey);
web3.eth.accounts.wallet.add(account);
web3.eth.defaultAccount = account.address;
const tx = {
from: web3.eth.defaultAccount,
to: toAddress,
value: web3.utils.toWei(amount, 'ether'),
gas: 21000,
gasPrice: web3.utils.toWei('1', 'gwei'),
chainId: 98985
};
web3.eth.sendTransaction(tx)
.then(receipt => {
console.log(`Transaction successful with hash: ${receipt.transactionHash} | Amount sent: ${amount} ETH | Next transaction in: ${interval} seconds`);
})
.catch(err => {
console.error('Error sending transaction:', err);
});
setTimeout(sendTransaction, interval * 1000);
}
sendTransaction();
rl.close();
});
});
});
});