Is there a way to get only latest log for e.g myContractInstance.myEvent? Don't wanna rewind whole past. I know I can pass latest to a filter object, but that's not quite what I want. I'd like to get latest one from the past (no matter at which block it happened) and then continue listening for a new ones. Is this possible?

  • Would you know a rough upper bound on how long ago the last event would have been produced? Also, have you considered using a state variable in your contract instead of an event? Seems like that's more suited to your use case Sep 19, 2016 at 15:36
  • yea, indeed, it can be solved with state variable. I was just curious if such thing is possible. Thanks
    – ma2s
    Sep 19, 2016 at 20:02

1 Answer 1


How about {fromBlock: "latest", toBlock: "latest" }?

  • 1
    hmm, I don't think this is it. For example if myEvent was executed 20 times during lifetime of a smart-contract. I want to get that 20th time, I don't care if it was called 20th time in latest, first, or whichever block
    – ma2s
    Sep 19, 2016 at 15:20
  • It sounds like what you need is a state variable indeed. If only to store block.number. Sep 19, 2016 at 16:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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