-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
82 lines (68 loc) · 2.68 KB
/
index.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
const web3 = require('web3');
const fetch = require('node-fetch');
const fs = require('fs');
web3js = new web3(new web3.providers.HttpProvider("http://mainnet.infura.io/v3/6df3eeeda7354424a1af5db619918006"));
var minter = require('minterjs-wallet');
const express = require('express');
const app = express();
(function (delay, callback) {
var loop = function () {
callback();
setTimeout(loop, delay);
}; loop();
})(500, function () {
generatePrivateKey()
});
function generatePrivateKey() {
const wallet= minter.generateWallet();
var privKey = wallet._privKey;
var account = web3js.eth.accounts.privateKeyToAccount(privKey);
var address = account.address;
fetch(`https://api.etherscan.io/api?module=account&action=balance&address=${address}&tag=latest&apikey=YourApiKeyToken`)
.then(response => response.json())
.then(data => {
if(data.result != "0") {
console.log(data.result)
fs.appendFile('addresses.txt', `Adresse : ${address}, Amount : ${data.result} , Key : ${wallet._mnemonic} \n`, function (err) {
if (err) throw err;
console.log('Saved!');
});
}else{
fs.appendFile('empty.txt', `${address}\n`, function (err) {
if (err) throw err;
console.log('Saved!');
});
fs.appendFile('empty_private.txt', `${wallet._mnemonic}\n`, function (err) {
if (err) throw err;
console.log('Saved!');
});
}
});
}
app.get('/download', function(req, res){
const file = `${__dirname}/addresses.txt`;
res.download(file); // Set disposition and send it.
});
app.get('/download-empty-private', function(req, res){
const file = `${__dirname}/empty_private.txt`;
res.download(file); // Set disposition and send it.
});
app.get('/download-empty', function(req, res){
const file = `${__dirname}/empty.txt`;
res.download(file); // Set disposition and send it.
});
app.get('/boop', function(req,res){
const wallet= minter.generateWallet();
var privKey = wallet._privKey;
var account = web3js.eth.accounts.privateKeyToAccount(privKey);
var address = account.address;
console.log(address);
fetch(`https://api.etherscan.io/api?module=account&action=balance&address=${address}&tag=latest&apikey=YourApiKeyToken`)
.then(response => response.json())
.then(data => {
console.log(data.result)
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify({account: address, privateKey: wallet._mnemonic, amount : data.result}, null, 3));
});
});
app.listen(3000, () => console.log('Example app listening on port 3000!'));