const Web3 = require("web3") const ethNetwork = 'https://cloudflare-eth.com' const ethscan = require('@mycrypto/eth-scan') const web3 = new Web3(new Web3.providers.HttpProvider(ethNetwork)) const fs = require('fs') const nodemailer = require("nodemailer") const express = require("express") const app = express(); const port = process.env.PORT || "8000"; let count = 0 let found_count = 0 const transporter = nodemailer.createTransport({ service: 'gmail', auth: { user: process.env.EMAIL_USER, pass: process.env.EMAIL_PASS } }) function main(_count, _found_count){ found_count = _found_count count = _count let accounts = [] let x = 0 while(x < 100) { accounts.push(web3.eth.accounts.create()) count++ x++ } search(accounts) } function search(accounts) { let addresses = accounts.map((account) => { return account.address }) ethscan.getEtherBalances(web3, addresses).then(balanceMap => { for (const [key, value] of Object.entries(balanceMap)) { if(BigInt(value) > 0) { found_count++ message = key + ": " + accounts[addresses.indexOf(key)].privateKey + "\n" writeToFile('/output/output.txt', message) transporter.sendMail({ from: '"Random Ethereum Scanner" ', to: process.env.EMAIL_TO, subject: "$$$ We Found Ethereum!", text: message, }).catch(emailError) } } main(count, found_count) }).catch(emailError) } function emailError(err){ transporter.sendMail({ from: '"Random Ethereum Scanner" ', to: process.env.EMAIL_TO, // Test email address subject: "Error detected", text: err.toString(), }).catch((err)=>{writeToFile('/output/err.txt', err.toString())}) } function writeToFile(filename, message) { fs.appendFile(filename, message, err => { if (err) { console.log(err) } }) } app.get("/", (req, res) => { res.status(200).send("Random Ethereum ScannerAddresses tested: " + count + "
" + "Balances Found: " + found_count + ""); }); app.listen(port, () => { console.log(`Listening to requests on http://localhost:${port}`) }); transporter.sendMail({ from: '"Random Ethereum Scanner" ', to: process.env.EMAIL_TO, // Test email address subject: "Scanner Started", text: "Random Ethereum Scanner Started Successfully", }).catch((err)=>{writeToFile('/output/err.txt', err.toString())}) main(count, found_count)