0

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.

Peter Mortensen
31.3k22 gold badges110 silver badges134 bronze badges
asked Aug 19, 2023 at 18:53
3
  • What is USDT? The ticker symbol for the Tether stablecoin cryptocurrency? Commented Aug 20, 2023 at 13:03
  • Re "it did not send usdt, but instead trx.": Literally "usdt" and "trx"? Commented Aug 20, 2023 at 13:08
  • TRX: "...a cryptocurrency native to the system, known as Tronix (TRX)" Commented Aug 20, 2023 at 13:11

1 Answer 1

0
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))))
answered Jan 29, 2024 at 17:41
Sign up to request clarification or add additional context in comments.

2 Comments

While this code snippet may be the solution, including an explanation really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion.
As suggested before, please consider adding an explanation of how your code attempts to answer the question.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.