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
-
What is USDT? The ticker symbol for the Tether stablecoin cryptocurrency?Peter Mortensen– Peter Mortensen2023年08月20日 13:03:15 +00:00Commented Aug 20, 2023 at 13:03
-
Re "it did not send usdt, but instead trx.": Literally "usdt" and "trx"?Peter Mortensen– Peter Mortensen2023年08月20日 13:08:14 +00:00Commented Aug 20, 2023 at 13:08
-
TRX: "...a cryptocurrency native to the system, known as Tronix (TRX)"Peter Mortensen– Peter Mortensen2023年08月20日 13:11:07 +00:00Commented Aug 20, 2023 at 13:11
1 Answer 1
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))))
Sign up to request clarification or add additional context in comments.
2 Comments
dan1st
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.
Ro.oT
As suggested before, please consider adding an explanation of how your code attempts to answer the question.
lang-py