-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
81 lines (63 loc) · 3.02 KB
/
main.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
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
from solc import compile_source
from web3 import Web3, HTTPProvider
import data
import constants
import time
import binascii
w3 = Web3(HTTPProvider(constants.INFURA_BACKEND))
# days to seconds
def days(val):
return val * hours(24)
# hours to seconds
def hours(val):
return val * 60 * 60
def get_abi(contract_name, filepath):
contract_source_code = open(filepath).read()
compiled_sol = compile_source(contract_source_code)
contract_interface = compiled_sol['<stdin>:' + contract_name]
return contract_interface['abi']
abi = get_abi('NucleusVisionAllocation', 'NucleusVisionAllocation.sol')
allocator = w3.eth.contract(constants.ALLOCATION_CONTRACT, abi=abi)
for presale in data.PRESALE:
address, tokens = presale
nonce = w3.eth.getTransactionCount(constants.PUBLIC_KEY)
txn = allocator.functions.mintTokens(address, tokens * (10 ** 18)).buildTransaction({'from': constants.PUBLIC_KEY, 'nonce': nonce})
signed_txn = w3.eth.account.signTransaction(txn, private_key=constants.PRIVATE_KEY)
txn_hash = w3.eth.sendRawTransaction(signed_txn.rawTransaction)
print ('Sent Transaction {}.'.format(binascii.hexlify(txn_hash)))
while w3.eth.getTransactionReceipt(txn_hash) == None:
time.sleep(10)
print ('Done Transaction {}.'.format(binascii.hexlify(txn_hash)))
print (w3.eth.getTransactionReceipt(txn_hash))
print ('\n\n\n')
for presale in data.PRESALE_BONUS:
address, tokens, cliff_days = presale
start = int(time.time() + hours(1))
cliff = days(cliff_days)
duration_days = cliff_days + 1
duration = days(duration_days)
nonce = w3.eth.getTransactionCount(constants.PUBLIC_KEY)
txn = allocator.functions.mintTokensWithTimeBasedVesting(address, tokens * (10 ** 18), start, cliff, duration).buildTransaction({'from': constants.PUBLIC_KEY, 'nonce': nonce})
signed_txn = w3.eth.account.signTransaction(txn, private_key=constants.PRIVATE_KEY)
txn_hash = w3.eth.sendRawTransaction(signed_txn.rawTransaction)
print ('Sent Transaction {}.'.format(binascii.hexlify(txn_hash)))
while w3.eth.getTransactionReceipt(txn_hash) == None:
time.sleep(10)
print ('Done Transaction {}.'.format(binascii.hexlify(txn_hash)))
print (w3.eth.getTransactionReceipt(txn_hash))
print ('\n\n\n')
for presale in data.ADVISORS:
address, tokens, cliff_days, duration_days = presale
start = 1511481600 # Nov 24th 2017
cliff = days(cliff_days)
duration = days(duration_days)
nonce = w3.eth.getTransactionCount(constants.PUBLIC_KEY)
txn = allocator.functions.mintTokensWithTimeBasedVesting(address, tokens * (10 ** 18), start, cliff, duration).buildTransaction({'from': constants.PUBLIC_KEY, 'nonce': nonce})
signed_txn = w3.eth.account.signTransaction(txn, private_key=constants.PRIVATE_KEY)
txn_hash = w3.eth.sendRawTransaction(signed_txn.rawTransaction)
print ('Sent Transaction {}.'.format(binascii.hexlify(txn_hash)))
while w3.eth.getTransactionReceipt(txn_hash) == None:
time.sleep(10)
print ('Done Transaction {}.'.format(binascii.hexlify(txn_hash)))
print (w3.eth.getTransactionReceipt(txn_hash))
print ('\n\n\n')