Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

usdt trc20 transaction revert error #113

Open
amvrcode opened this issue Feb 14, 2024 · 0 comments
Open

usdt trc20 transaction revert error #113

amvrcode opened this issue Feb 14, 2024 · 0 comments

Comments

@amvrcode
Copy link

I am sending a usdt trc20 transaction and I get this error:

Screenshot 2024-02-14 в 17 10 49

https://tronscan.org/#/transaction/b84056753a8c9523f21749879a15960a8d5a44fb7f9e4d13c23443dfb9e10d16

{'result': True, 'txid': 'b84056753a8c9523f21749879a15960a8d5a44fb7f9e4d13c23443dfb9e10d16', 'transaction': {'visible': False, 'txID': 'b84056753a8c9523f21749879a15960a8d5a44fb7f9e4d13c23443dfb9e10d16', 'raw_data': {'contract': [{'parameter': {'value': {'data': 'a9059cbb0000000000000000000000000e10266d5f351334ddc65ce5e50b09d557abf15400000000000000000000000000000000000000000000000000000000000f4240', 'owner_address': '4188cd72aba048a0acf9175b754b4255e285be204a', 'contract_address': '41a614f803b6fd780986a42c78ec9c7f77e6ded13c', 'call_value': 10}, 'type_url': 'type.googleapis.com/protocol.TriggerSmartContract'}, 'type': 'TriggerSmartContract'}], 'ref_block_bytes': 'b24a', 'ref_block_hash': '74833d116005ac39', 'expiration': 1707915852000, 'fee_limit': 100000000, 'timestamp': 1707915792651}, 'raw_data_hex': '0a02b24a220874833d116005ac3940e0f1debdda315ab001081f12ab010a31747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e54726967676572536d617274436f6e747261637412760a154188cd72aba048a0acf9175b754b4255e285be204a121541a614f803b6fd780986a42c78ec9c7f77e6ded13c180a2244a9059cbb0000000000000000000000000e10266d5f351334ddc65ce5e50b09d557abf15400000000000000000000000000000000000000000000000000000000000f4240708ba2dbbdda31900180c2d72f', 'signature': ['16a9ce035c7f01069b5061cbd7d5407671dad625a4fbcc2d418c50f99b7d067815fa911d1207bd063ce7ec4c448896264d55be2f6b935911e1866d1b05a7e3f21b']}}

My code:

def send_usdt(payment_amount, payment_address):
    from tronapi import Tron
    full_node = 'https://api.trongrid.io'
    solidity_node = 'https://api.trongrid.io'
    event_server = 'https://api.trongrid.io'

    pkey = "A7E349B************C04C1E10"
    tron = Tron(full_node=full_node,
        solidity_node=solidity_node,
        event_server=event_server)
    print(tron.toSun(0.2))
    tron.private_key = pkey
    tron.default_address = tron.address.from_private_key(pkey).base58
    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") 
    kwargs["function_selector"] = "transfer(address,uint256)" 
    kwargs["fee_limit"] = 100000000
    kwargs["call_value"] = 10
    payment_amount = int(float(payment_amount))
    kwargs["parameters"] = [
    {
    'type': 'address',
    'value': tron.address.to_hex(payment_address)
    },
    {
    'type': 'uint256',
    'value': payment_amount * 1000000 
    }
    ]

    raw_tx = tron.transaction_builder.trigger_smart_contract(**kwargs)
    print(raw_tx)
    print("++++++++++++++++++")
    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")
    return result

please tell me what I'm doing wrong. how do I fix my code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant