0

My code:

mainContract.events.Transfer({
    fromBlock: 0
}, function (error, event) {
    console.log(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?

1

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.