I am developing a Dapp that contains a notification between two Users. for example :

  • User 1 (Student): send a transaction that contains data to be confirmed.

  • User 2 (Professor): receive a notification to validate the student data.

  • User 1 (Student): receive a notification about the professor answer.

is't possible to implement this use case using smart contract events? I took a look to web3.shh but it seems like it miss documentation


You can doing that by create your event in your Smart Contract like :

event StudentData(address indexed _professorAddr, string indexed _studentData)

Then, using web3 api you can watch/listen for this events by filtering on the professor address by exemple, and trigger any action, like a notification, when the event realise

See documentation about events listening.

| improve this answer | |
  • thnks for your quick answer. but how much time can an event live? let's say the professor will open the app after 3 week of the student submission ? – maroodb May 3 '18 at 8:43
  • According Solidity Documentation about events, it seems that events logs are stored in the blockchain, so the events are keep alive a long time that blockchain is alive I think. So in your case, when the professor open the Dapp the watch for event function start to listen from the first block to latest one and show you all of them. – Lbrth_BoC May 3 '18 at 8:57

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.