kopanitsa / web3-arduino

an Arduino (or ESP32) library to use web3 on Ethereum platform.
MIT License
105 stars 45 forks source link

Listen to Contract events #5

Open Timvdv opened 6 years ago

Timvdv commented 6 years ago

Hi,

I'm wondering if it's possible to use this library to listen to events triggered by the smart contract.

https://github.com/ethereum/wiki/wiki/JavaScript-API#contract-events

I could not find it in the examples.

Thanks,

Tim

publu commented 6 years ago

You might want to read the code and see how to listen for changes

Timvdv commented 6 years ago

@publu I did that and could not find the implementation. So I might have missed it, or it's not implemented yet.

I do understand that the contract event listener requires a websocket connection which I'm not even sure if it's supported on the ESP32.

Just polling could also do the trick. If we could implement the contract.getPastEvents function we can kindof work around the websockets. Not as nice because the http provider is deprecated in the latest web3 version. But for the ESP32 it's probably the best solution.

kopanitsa commented 6 years ago

Sorry for my late reply. This is not implemented yet, but I'd like to implement it asap. Sorry for slow speed of development :(

Timvdv commented 6 years ago

No problem! At the moment I'm working with the NodeJS web3 version on the Raspberry Pi. But I would love to implement it on my ESP32. Unfortunately my knowledge of C is not that great, otherwise I would've helped you with the development. However I might be able to test the implementation when It's done 😃