0

I'm using Infura as my provider. From what I've read online, it seems that using a websocket with infura instead of http is the first step to being able to hear events however I only get an empty list when I retrieve all the latest events

I have a script that causes the contract to emit an event every 20 seconds.

This is what I'm using to test hearing events

    events = contract_ws.events.Transfer.createFilter(fromBlock="latest", toBlock="pending").get_all_entries()
    if (len(events) != 0):
        break
    else:
        print("Not yet.")
        time.sleep(3)

But it never breaks out of the loop so therefore never hears an event. What am I missing?

I'm using the web3py library but I don't think that'll effect the solution.

  • 1. "It seems that if I have as long as I use websocket instead of http provider than I should be able to here events". – goodvibration Mar 24 at 7:36
  • 2. "But it never hears an event". – goodvibration Mar 24 at 7:36
  • Please resolve the conflict between these two opposite statement! – goodvibration Mar 24 at 7:36
  • I updated the question to be more clear. From what I've read online, it seems that it is impossible to hear events with an http provider and should be possible with a websocket, however I've yet to hear any events. – financial_physician Mar 24 at 17:58
  • It's got nothing to do with the connection type. Think about it - why would this layer in the communication protocol have any impact whatsoever on what type of data is provided in a (much) higher layer? – goodvibration Mar 24 at 18:05

Your Answer

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

Browse other questions tagged or ask your own question.