1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] send USDT TRC20 by python

Discussão em 'Python' iniciado por Stack, Setembro 11, 2024.

  1. Stack

    Stack Membro Participativo

    How can I send usdt trc20 to another address?

    Here is what i tried to do:

    USDT_CONTRACT_ADDRESS = "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"
    USDT_CONTRACT_ABI = [
    {
    "constant": False,
    "inputs": [
    {"name": "_to", "type": "address"},
    {"name": "_value", "type": "uint256"}
    ],
    "name": "transfer",
    "outputs": [{"name": "", "type": "bool"}],
    "payable": False,
    "stateMutability": "nonpayable",
    "type": "function"
    }
    ]
    def send_usdt_transaction(sender_address,sender_private_key, receiver_address, amount, api_key):
    client = Tron(provider=HTTPProvider(api_key=api_key))

    private_key = PrivateKey(bytes.fromhex(sender_private_key))

    contract = Contract(
    addr=USDT_CONTRACT_ADDRESS,
    bytecode="",
    name="USDT",
    abi=USDT_CONTRACT_ABI,
    client=client
    )

    amount_in_sun = int(amount * 1_000_000)

    txn = (
    contract.functions.transfer(receiver_address, amount_in_sun)
    .with_owner(sender_address)
    .fee_limit(50_000_000)
    .build()
    .sign(private_key)
    )

    txn_hash = txn.broadcast()


    return txn_hash



    I have updated the code. now I made this transaction https://tronscan.org/#/transaction/86c01587c17031328028506adb2db12244830b595ebfd7e157c587c28824b90d But I get error: FAILED -OUT OF ENERGY> as you can see I increased the fee_limit too

    Continue reading...

Compartilhe esta Página