How to send USDT TRC20 via Python

590 views Asked by At

How can I send USDT TRC20 via Python?

I used this code:

from tronpy import Tron
from tronpy.keys import PrivateKey

client = Tron(network='mainnet')
priv_key = PrivateKey(bytes.fromhex("0"))

txn = (
    client.trx.transfer(from_="0", to="0", amount=1_000)
    .memo("0")
    .build()
    .sign(priv_key)
)
print(txn.txid)
print(txn.broadcast().wait())

But it did not send usdt, but instead trx.

A network change does not help.

1

There are 1 answers

2
StasFQ On
contract = tron.get_contract('TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t')
tx = (
         contract.functions.transfer(address_to, amount)
         .with_owner(your_address)
         .fee_limit(your fee)
         .build()
         .sign(PrivateKey(bytes.fromhex(your pk))))