-
Notifications
You must be signed in to change notification settings - Fork 19
/
raw_deploy.py
43 lines (33 loc) · 986 Bytes
/
raw_deploy.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
from os import getenv
from dotenv import load_dotenv
from net import con
w3 = con()
def return_account():
load_dotenv()
return { 'addr': getenv('tron'), 'key': getenv('key') }
def sign_tx(tx, key):
sig = w3.eth.account.sign_transaction
return sig(tx, private_key=key)
def send_tx(signed_tx):
w3.eth.send_raw_transaction(signed_tx.rawTransaction)
return w3.toHex(w3.keccak(signed_tx.rawTransaction))
def main():
account = return_account()
nonce = w3.eth.get_transaction_count(account['addr'])
tx = {
'from': account['addr'],
'value':0,
'chainId': 42,
'gas': 500000,
'maxFeePerGas': w3.toWei('50', 'gwei'),
'maxPriorityFeePerGas': w3.toWei('40', 'gwei'),
'nonce': nonce
}
data = ''
with open('vy/test.bin', 'r') as f:
data = f.read()
tx.update({'data': data.strip()})
sent = send_tx(sign_tx(tx, account['key']))
print (f'sent: {sent}')
if __name__ == '__main__':
main()