Açtığımız dosyaya aşağıdaki komutları, hiçbir yerine dokunmadan ekleyip. CTRL X Y enter ile çıkıyoruz.
const readline = require('readline');
const Web3 = require('web3');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.question('Enter your MetaMask wallet private key: ', (privateKey) => {
rl.question('Enter the wallet address you want to send to: ', (toAddress) => {
rl.question('Enter the amount you want to send (in tevmos): ', (amount) => {
rl.question('How often do you want to repeat the transaction? (in seconds): ', (interval) => {
const rpcURL = "http://localhost:8545"; // or your server's IP: "http://your-server-ip:8545"
const web3 = new Web3(new Web3.providers.HttpProvider(rpcURL));
function sendTransaction() {
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')
};
web3.eth.sendTransaction(tx)
.then(receipt => {
console.log('Transaction successful with hash:', receipt.transactionHash);
})
.catch(err => {
console.error('Error sending transaction:', err);
});
}
setInterval(sendTransaction, interval * 1000);
rl.close();
});
});
});
});
Yeni bir screen açalım
screen -S autotx
Scriptimizi başlatıyoruz.
node airchainstx.js
Bizden bazı bilgileri isteyecek, sırasıyla yazıyorum.
MetaMask wallet private key bunu bulmak için /bin/bash ./scripts/local-keys.sh ile aldığımız private key giriyoruz.
Enter the wallet address you want to send to göndermek istediğimiz bir cüzdan adresi yazıyoruz. İstediğinizi yazabilirsiniz.
Enter the amount you want to send göndermek istediğiniz miktarı yazıyorsunuz . 1,2,3 veya istediğiniz bir miktar.
How often do you want to repeat the transaction burada ne kadar sürede bir gönderim yapacak onu seçiyoruz. 30,40,50 saniye tam sayı olarak girebilirsiniz.
Bu şekilde TX'ler görmeye başladıysanız, işlem tamamdır.