Skip to content

Instantly share code, notes, and snippets.

@sh4dowb
Last active March 16, 2024 18:55
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sh4dowb/43ed4839acdd81a36e1418379111d8ea to your computer and use it in GitHub Desktop.
Save sh4dowb/43ed4839acdd81a36e1418379111d8ea to your computer and use it in GitHub Desktop.
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 # 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")
@mwendwa5
Copy link

mwendwa5 commented Aug 9, 2022

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.'}

@ikamran
Copy link

ikamran commented Jan 21, 2023

I am also want to send from a multi signature wallet which i have the same problem!

@ketlller
Copy link

?????? 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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment