Skip to content

Instantly share code, notes, and snippets.

@sh4dowb
Created Aug 26, 2021
Embed
What would you like to do?
tronapi python mass USDT payment - send mass USDT payments with python
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 # I have no idea
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")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment