-
Notifications
You must be signed in to change notification settings - Fork 19
/
raw_approval.py
42 lines (33 loc) · 5.41 KB
/
raw_approval.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
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):
return w3.eth.account.sign_transaction(tx, private_key=key)
def send_tx(signed_tx):
return w3.eth.send_raw_transaction(signed_tx.rawTransaction)
def main():
account = return_account()
nonce = w3.eth.get_transaction_count(account['addr'])
function = '095ea7b3'
address = '0000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b47997506'
amount = '0000000000000000000000000000000000000000000000000000000000989680'
data = '0x' + function + address + amount
tx = {
'from' : account['addr'],
'to' : '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270',
'value' : 0,
'chainId': 137,
'gas' : 250000,
'maxFeePerGas': w3.eth.gas_price * 2,
'maxPriorityFeePerGas': w3.eth.max_priority_fee * 2,
'nonce' : nonce,
'data' : data
}
sent = send_tx(sign_tx(tx, account['key']))
print (f'hash: {sent}')
if __name__ == '__main__':
main()