My code:

    fromBlock: 0
}, function (error, event) {

This method returns all the past events (I guess because of that fromBlock: 0)

Now my question is how can I set this to only watch for new events?


Instead of zero you can use "latest", other commonly used block is "pending".

See web3's documentation for a better explanation.

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.