andelf / tronpy

TRON Python Client Library.
MIT License
212 stars 96 forks source link

Dear author, how to monitor the Transfer event of TRC20? #122

Closed DINGYIOK closed 8 months ago

DINGYIOK commented 10 months ago

For example, like the contract.on method in ethers.js, or like the contract.Transfer().watch method in TronWeb? I hope dear author can reply to me

danielqba commented 10 months ago

I think you can scan all tx in a block and check for the contract of every one of them!?

DINGYIOK commented 10 months ago

Yes bro, I'm already doing this, getting the latest block and traversing the details of the txID to get it, but it's a waste of resources

danielqba commented 10 months ago

I don't think there's another way around that! In theory, you could monitor the balance of the account every minute, and if it changed, go backward a few blocks and scan them one by one!??? I guess that could work?

danielqba commented 10 months ago

I don't think there's another way around that! In theory, you could monitor the balance of the account every minute, and if it changed, go backward a few blocks and scan them one by one!??? I guess that could work?

I guess this could work if you don't have to watch too many addresses, or too many contracts.

MrNaif2018 commented 8 months ago

Yes bro, I'm already doing this, getting the latest block and traversing the details of the txID to get it, but it's a waste of resources

It is not a waste of resources. One block contains at the absolute maximum like 400 transactions. This is not hard to parse. In general you should just use Bitcart to process payments in tron with ease, it's already implemented