Giter VIP home page Giter VIP logo

Comments (6)

congnghiakhiem avatar congnghiakhiem commented on August 11, 2024 1

`
def check_trasaction(trans):
for trx in trans:
trx_id = trx["txID"]

    if trx["ret"][0]["contractRet"] == "SUCCESS":
        contract = trx["raw_data"]["contract"][0]
        contract_type = contract["type"]

        if contract_type == "TriggerSmartContract":
            contract_address = contract["parameter"]["value"]["contract_address"]
            if contract_address == USDT_CONTRACT:
                                    
                if data[:8] == "a9059cbb":
                    from_addr = contract["parameter"]["value"]["owner_address"]
                    to_addr = to_base58check_address('41' + (data[8:72])[-40:])
                    amount = int(data[-64:], 16)
                    ...

                elif data[:8] == "23b872dd":
                    from_addr = to_base58check_address('41' + (data[8:72])[-40:])
                    to_addr = to_base58check_address('41' + (data[72:136])[-40:])
                    amount = int(data[-64:], 16)
                    ...

`

from tronpy.

congnghiakhiem avatar congnghiakhiem commented on August 11, 2024

I have same problem. I have extracted first 8 character for contract method. But some transaction have got error

if data[:8] == "a9059cbb":
text = trx_abi.decode_abi(['address', 'uint256'], bytes.fromhex(data[8:]))
print(text)
elif data[:8] == "23b872dd":
text = trx_abi.decode_abi(['address', 'address', 'uint256'], bytes.fromhex(data[8:]))
print(text)

32108025 => block number
4c6e0524d6b8656d0ffe97042320da9f03aa8def25b360a7f202ec14f4767abe => transaction
000000000000000000000000002a9e91d7625c0bc85cf05cfe28e4341c28ae080000000000000000000000000000000000000000000000000000000114868ed0
('T9z64JoRNvbMEicZ5PCJhqkcauN5DUksge', 4639330000)

04ffeedd850c24b0a144360f295adac36e517ae694f328a4dd3cab609b5c2f6d
000000000000000000000000fbdba300903ce296b6c8789ca018fe7682cbe507000000000000000000000000f41ee1a3e3a18e2aa250ae9c1e490292985f86ba0000000000000000000000000000000000000000000000000000000039a143f0
('TYvuiqRqr74KXPXXgKx6ncJbX2tob6JtSa', 'TYDzsYUEpvnYmQk4zGP9sWWcTEd2MiAtW6', 966870000)

d61a5ca5fa27d574ebc79c6241574beb0475862c363345ddeeb9393bcd2540d3
0000000000000000000000416128ae4b8cdf4e4ef499457cc285e9d12c55fc5e00000000000000000000000000000000000000000000000000000001dcca1b00
Traceback (most recent call last):
File "C:\Projects\PyTools\trc20\usdt_listener.py", line 98, in
asyncio.run(listen_usdt_transfer())
File "C:\Python39\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Python39\lib\asyncio\base_events.py", line 642, in run_until_complete
return future.result()
File "C:\Projects\PyTools\trc20\usdt_listener.py", line 82, in listen_usdt_transfer
check_trasaction(block["transactions"])
File "C:\Projects\PyTools\trc20\usdt_listener.py", line 38, in check_trasaction
text = trx_abi.decode_abi(['address', 'uint256'], bytes.fromhex(data[8:]))
File "C:\Python39\lib\site-packages\eth_abi\codec.py", line 181, in decode_abi
return decoder(stream)
File "C:\Python39\lib\site-packages\eth_abi\decoding.py", line 127, in call
return self.decode(stream)
File "C:\Python39\lib\site-packages\eth_utils\functional.py", line 45, in inner
return callback(fn(*args, **kwargs))
File "C:\Python39\lib\site-packages\eth_abi\decoding.py", line 173, in decode
yield decoder(stream)
File "C:\Python39\lib\site-packages\eth_abi\decoding.py", line 127, in call
return self.decode(stream)
File "C:\Python39\lib\site-packages\eth_abi\decoding.py", line 201, in decode
self.validate_padding_bytes(value, padding_bytes)
File "C:\Python39\lib\site-packages\eth_abi\decoding.py", line 332, in validate_padding_bytes
raise NonEmptyPaddingBytes(
eth_abi.exceptions.NonEmptyPaddingBytes: Padding bytes were not empty: b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00A'

from tronpy.

congnghiakhiem avatar congnghiakhiem commented on August 11, 2024

I change to use to_base58check_address for decode and it works

from tronpy.

ripinghot avatar ripinghot commented on August 11, 2024

I change to use to_base58check_address for decode and it works

hello @congnghiakhiem
can you write down your code that how you fix this problem ?
i have the same problem and i dont figure it out

from tronpy.

danielqba avatar danielqba commented on August 11, 2024

@ripinghot Hello!

Did you find any solution?

from tronpy.

MrNaif2018 avatar MrNaif2018 commented on August 11, 2024

Fixed by b8b48ca, originally introduced in #36

from tronpy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.