tronprotocol / tronweb

Javascript API Library for interacting with the TRON Network
MIT License
440 stars 277 forks source link

Incomplete Transfer Event Emission with Tronweb's contract.Transfer().watch() #375

Closed ayzerobug closed 1 year ago

ayzerobug commented 1 year ago

I am currently developing a payment solution utilizing USDT-TRC20 on the Tron blockchain using Tronweb. However, I have encountered an issue where the contract.Transfer().watch() function does not emit all transfers occurring within the contract. As a result, when comparing the transaction hashes obtained from Tronscan to the existing records, the newly obtained transaction hashes do not appear in the watchlist.

Please provide a solution or guidance on how to ensure that all transfers within the contract are properly emitted and captured by the contract.Transfer().watch() function.

Thank you for your attention to this matter.

DmytroShalaiev commented 1 year ago

I would not use this method. Open the source it's just a loop with a delay of 3 seconds that calls this.tronWeb.event.getEventsByContractAddress.

DmytroShalaiev commented 1 year ago

By default it's use block tag 'latest' in simple loop with delay it can be problem(missing blocks)

ayzerobug commented 1 year ago

Yes, i checked the source code and notice the watch method is just a loop of the getEvents method at 3 seconds interval while the getEvents get only events of 1 seconds earlier. Hence missing transfers within 2 seconds