-
-
Save sh4dowb/43ed4839acdd81a36e1418379111d8ea to your computer and use it in GitHub Desktop.
import time | |
from tronapi import Tron | |
full_node = 'https://api.trongrid.io' | |
solidity_node = 'https://api.trongrid.io' | |
event_server = 'https://api.trongrid.io' | |
pkey = "private_key_hex" | |
payments = [ | |
["150", "T1...."], | |
["50.25", "T2..."], | |
] | |
# USDT amount, address | |
tron = Tron(full_node=full_node, | |
solidity_node=solidity_node, | |
event_server=event_server) | |
tron.private_key = pkey | |
tron.default_address = tron.address.from_private_key(pkey).base58 | |
for payment_amount,payment_address in payments: | |
trx_kwargs = dict() | |
trx_kwargs["private_key"] = pkey | |
trx_kwargs["default_address"] = tron.address.from_private_key(pkey).base58 | |
tron = Tron(**trx_kwargs) | |
kwargs = dict() | |
kwargs["contract_address"] = tron.address.to_hex("TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t") # USDT contract address | |
kwargs["function_selector"] = "transfer(address,uint256)" # function to call and types. for reference on tronscan it looks like this: transfer(address _to,uint256 _value) | |
kwargs["fee_limit"] = 5000000 # fee limit in tron (5 TRX here) | |
kwargs["call_value"] = 0 # how much tron to send to the contract (always keep this zero for transferring tokens) | |
payment_amount = int(float(payment_amount)) | |
kwargs["parameters"] = [ | |
{ | |
'type': 'address', | |
'value': tron.address.to_hex(payment_address) | |
}, | |
{ | |
'type': 'uint256', | |
'value': payment_amount * 1000000 # 1000000 = 1 USDT | |
} | |
] | |
raw_tx = tron.transaction_builder.trigger_smart_contract(**kwargs) | |
signed = tron.trx.sign(raw_tx["transaction"]) | |
print(f"\n\nSENDING {payment_amount} USDT TO {payment_address} IN 2 SEC...\n") | |
time.sleep(2) | |
result = tron.trx.broadcast(signed) | |
print("RESULT", result, "\n\n") |
This code uses energy and bandwidth but does not transfer usdt. why ?!!!
hi, it worked the last time I tried. what is the result? do you have a txid?
maybe try increasing fee_limit , if error is "run out of gas"
RESULT {
'result': True,
'txid': '62f1c9de48dcd19b054a8316f1bec045d7e6cb21f3f6d1f67c7574ad0c53672d',
'transaction': {
'visible': False,
'txID': '62f1c9de48dcd19b054a8316f1bec045d7e6cb21f3f6d1f67c7574ad0c53672d',
'raw_data': {
'contract': [{
'parameter': {
'value': {
'data': 'a9059cbb00000000000000000000000008e6e1b7b7b4a30eb955da57b67700cf81f0d3d500000000000000000000000000000000000000000000000000000000003d0900',
'owner_address': '419feb3472d39b1a859e8eef87983d1a915c888823',
'contract_address': '41a614f803b6fd780986a42c78ec9c7f77e6ded13c'
},
'type_url': 'type.googleapis.com/protocol.TriggerSmartContract'
},
'type': 'TriggerSmartContract'
}],
'ref_block_bytes': '28bd',
'ref_block_hash': '2cf3e57404037d8f',
'expiration': 1659778725000,
'fee_limit': 5000000,
'timestamp': 1659778666964
},
'raw_data_hex': '0a0228bd22082cf3e57404037d8f4088e99594a7305aae01081f12a9010a31747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e54726967676572536d617274436f6e747261637412740a15419feb3472d39b1a859e8eef87983d1a915c888823121541a614f803b6fd780986a42c78ec9c7f77e6ded13c2244a9059cbb00000000000000000000000008e6e1b7b7b4a30eb955da57b67700cf81f0d3d500000000000000000000000000000000000000000000000000000000003d090070d4a39294a7309001c096b102',
'signature': ['27546f23708446e0efd47d2aab7d0c5ce81c2d6dd489fe1d1ee3be13b13a570e28c51cd75aa2a696d88b3a84e403c394d2a76cc0eddbd2f6ec89855a0c10843f1c']
}
}
this is result
this is result
as seen on tronscan, it returned "Failed -Out of Energy>"
you can try increasing kwargs["fee_limit"] = 5000000
to kwargs["fee_limit"] = 20000000
(20 TRX) and try again
Thank you for your guidance
Yes, the transfer was done by increasing the fee limit.
that was perfect
<3 <3 <3 ;)
This is not working on my side. I do not have multi-signature authority. See result below.
RESULT {'code': 'SIGERROR', 'txid': '3455e6e8e17b2ac99725bf461cde9b505a5f5d516770f5f551700d3e2f7441d9', 'message': 'Validate signature error: 09a1c7cdf01973d5704f9469606a814a83107583c96b6ada4e7dc17c280f417e22d5d68fe7c607c682b8d12712a1d8adf2875cd9061e4de4d95094bdb65c2d641c is signed by TKx1TtevcLSMst73ZRZLKfVc7wEfpVwuBn but it is not contained of permission.'}
I am also want to send from a multi signature wallet which i have the same problem!
?????? WhAT IS THIS???
from eth_abi import (
ImportError: cannot import name 'encode_abi' from 'eth_abi' (C:\Users\BOT\AppData\Local\Programs\Python\Python38\lib\site-packages\eth_abi_init_.py)
This code uses energy and bandwidth but does not transfer usdt.
why ?!!!