Comments (6)
`
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.
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.
I change to use to_base58check_address for decode and it works
from tronpy.
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.
@ripinghot Hello!
Did you find any solution?
from tronpy.
Fixed by b8b48ca, originally introduced in #36
from tronpy.
Related Issues (20)
- how i send trx with float HOT 2
- network is the test network. Why is the query still about the main network HOT 1
- 'Tron' object has no attribute 'generate_address_with_mnemonic' HOT 1
- LOCK_PERIOD is not included for delegate_resource HOT 6
- getDelegatedResourcev2 not included
- GetDelegatedResourceAccountIndexV2 not included (important) HOT 7
- GetCanDelegatedMaxSize not included HOT 2
- How to perform Estimated energy HOT 1
- Function get_function_by_selector returning None HOT 1
- delegate_resource cannot be used HOT 1
- Dear author, how to monitor the Transfer event of TRC20? HOT 5
- Error while trying to query how much usdt is in a wallet HOT 1
- ABI error when using HTTPProviver over just nile network HOT 2
- delete issue
- Got 403 Forbidden when use AsyncTron HOT 1
- TypeError: provider is not a HTTPProvider when using AsyncHTTPProvider HOT 1
- calculate the bandwidth HOT 1
- tronpy.exceptions.ValidationError: Contract validate error : No contract or not a smart contract
- I am unable to pay TRX when interacting with the contract HOT 1
- Wrong annotation of get_bandwidth HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tronpy.