0

After reading a bit of documentation about events and reading some answers here, I don't really get why events are useful in solidity.

Emit an "event" means to notify listeners about something that has happened. But, in solidity events just seem to be stored in the transaction logs when they are emited. Don't seem to notify anyone.

Are the ones that want to listen to changes poll the transaction logs every now and then to check if something has happened?.

1 Answer 1

0

Events do not notify in the sense of sending an email or sms notification but they are a bit like logs contained in the blockchain.

The advantage is that they are not very expensive in terms of gas as opposed to a string type variable, that's why we use them.

The notification of these events is limited to write a string in the blockchain when a function is executed, but their scope stops there.

You can then create a bot that listens to these events and then sends "real" notifications like an email or other action.

2
  • So, as I stated before, if I want to connect an app to a contract, to know what have happened, for example to update some values in a frontend, the only way I can do this is through polling the new blocks and checking the event transaction logs?
    – Notbad
    Sep 16, 2021 at 9:59
  • @Notbad exactly !
    – n1c01a5
    Sep 16, 2021 at 10:02

Your Answer

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

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