-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathairdrop.js
115 lines (105 loc) · 2.87 KB
/
airdrop.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
var config = require('./config')
var path = require('path')
var curDir = path.resolve(__dirname, '.')
var dbHelper = require('./dbhelper')
var EosHelper = require('./eoshelper');
const topAccounts = [
'eos',
'geydmnrzgene',
'gy4tiobtgene',
'bijingaaaaaa',
'gm3doobqgene',
'godofwealths',
'gy2dcmjzgige',
'fuckyoumommm',
'airdropsdac1',
'sayyousayme1',
'wangruixiwww',
]
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function getAccounts() {
if (config.db) {
let sql = ' select name from accounts where ram > 5 and balance > 200 and issued=0 order by id desc;'
let accounts = await dbHelper.executeSql(sql);
return accounts.map(item => item.name)
} else {
console.log("top accounts");
return topAccounts;
}
}
async function airdrop(memo) {
console.log("airdrop start")
if (memo == null) {
memo = config.memo;
}
let accounts = await getAccounts();
for (let account of accounts) {
await _airdrop(account, memo)
await sleep(1000)
}
console.log("airdrop finished")
}
async function markDropped(account) {
let newItem = {
issued:1,
}
let sql = "update accounts set ? where name='" + account + "'";
try {
await dbHelper.executeSql(sql, newItem, true);
} catch (error) {
throw "update drop error," + error;
}
}
async function _airdrop(account, memo) {
if (!account) {
return false;
}
console.log("airdrop to", account)
try {
tr = await eos.transaction(eos =>
{
eos.transfer(config.issuer, account, '0.0001 EOS', memo)
}
)
// Token transfer sample
// Uncomment below to transfer token
/*tr = await eos.transaction(
{
// ...headers,
actions: [
{
//contract account
account: 'ethsidechain',
name: 'transfer',
authorization: [{
actor: your_account,
permission: 'active'
}],
data: {
from: from_account,
to: to_account,
quantity: '' + parseInt(amount).toFixed(4) + ' EETH',
memo: account + '提币' + amount + " EETH",
}
}
]
}
// options -- example: {broadcast: false}
)*/
await markDropped(account)
return false;
} catch (e) {
console.log("fail", e)
return false;
}
return true;
}
async function start() {
if (config.db) {
await dbHelper.init();
}
await airdrop(null);
}
start()