0

Hi this is my web3 code

events.watch(function (error,result){
            if (error) {
                console.log('Error:'+JSON.stringify(error));
                res.send({'status':0,'message':error});
            }else{
                console.log('Result:'+JSON.stringify(result));
                res.send({'status':1,'message':result});

            }
        });

Here when ever an event occurs it trigger the watch function. But the problem is, it callback the function, twice. How can I prevent this? In every discussion they just said I fixed and closed the thread. What is the solution to stop triggering twice? I'm using web3 0.20.0. Thank you.

0

You could create a hash list based on the transaction's hash and make sure it was not processed before running the code

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.