Please follow and like us:

If you are creating dapp on the Tron blockchain, you properly will face one issue with Event Watcher using TronWeb. The issue is the watch() promise doesn’t detect event emission consistently and many occasions it never triggered.

In the smart contract you define an Event like this:

event RandomNumber(uint256 _rand,uint8[] array27);

And when you want to send the event to the blockchain, you emit it:

emit RandomNumber(randno,ranNumbers);

The Tron blockchain will save the smart contract event and anyone can query to see the event information. However, for some reason, in TronWeb JS using ReactJS doesnt work very well.

In general, you will use this watch function to detect Event Emitted:

Utils.contract. RandomNumber().watch((err, { result }) => {
      //Your Code here
      }).catch(err => {
          console.log('Error LoseBet',err);

I have experienced the issue and took me very long time to solve. The solution is to use TronGrid JS to directly read the event in Tron Blockchain. TronGrid speed is excellent and information of any transactions appear almost immediately. The options are to filter what kind of events you want to get. In this case, I filtered the event using block timestamp.

const options = {
   minBlockTimestamp: _timestamp,
const trans = await this.tronGrid.contract.getEvents(contractAddress,options).then(transactions => {
         //Your code here
}).catch(err => console.error(err));

Information about TronGrid can be found at

To Install TronGrid, simple enter this code in your project folder.

npm install trongrid

Then import it to ReactJs project

import TronGrid from "trongrid";

this.tronGrid = new TronGrid(window.tronWeb);

Hope it helps and if you have any question regarding the Event issue, please leave a message or contact me.

Please follow and like us:
TronWeb js Event watcher issue and solution – ReactJS
Tagged on:                                 

Leave a Reply

error: Content is protected !!