This repository has been archived by the owner on Aug 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathautomated_airdrop.py
55 lines (46 loc) · 2.47 KB
/
automated_airdrop.py
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
#!/usr/bin/env python3
import os, json
from datetime import datetime
import lib.rpc_json as rpc_json
import lib.utility_func as utility_func
class task():
def __init__(self):
self.relative_path = os.path.dirname(os.path.abspath(__file__))
self.config = utility_func.load_json(f'{self.relative_path}/config/setup.json')
self.sent = utility_func.load_json(f'{self.relative_path}/data/persistent-sent.json')
self.airdropConf = utility_func.load_json(f'{self.relative_path}/data/current-airdrop.json')
self.wallet = utility_func.load_json(f'{self.relative_path}/config/wallet-config.json')
self.batch_log = f'{self.relative_path}/batch-log.txt'
# debugging; log time each batch task has been completed
def task_logging(self):
batch_log = open(self.batch_log, 'a')
batch_log.write(f'[{datetime.now()}] - Batch airdrop complete!\n')
def batch_airdrop(self):
if self.airdropConf['twitter-bounty']:
for user in self.airdropConf['airdrop-users']:
self.sent['sent'].append(user)
# "[1:]" added to remove . <- period from filepath
update_sent = json.dumps(self.sent)
utility_func.jsonfile(self.relative_path + self.config['sent'][1:], update_sent)
if self.airdropConf['active']:
if rpc_json.txConfirmation() >= self.wallet['confirmations']:
for user in self.airdropConf['airdrop-users']:
if len(self.airdropConf['airdrop-users']) == 0:
break
else:
rpc_json.addParticipant(user['address'], self.airdropConf['amount'])
# send transactions
rpc_json.sendCoins()
rpc_json.clearRecipients()
# change 'current-airdrop.json' by moving participants to 'persistent-sent.json'
self.airdropConf['airdrop-users'] = []
update_airdropConf = json.dumps(self.airdropConf)
utility_func.jsonfile(self.relative_path + self.config['airdrop'][1:], update_airdropConf)
self.task_logging()
else:
print ("Not enough confirmations")
else:
print ("Not private, this shouldn't print. If it does.. something broke")
else:
print ("Airdrop isn't persistent.")
task().batch_airdrop()