What is an Event?

Are they only used in Solidity?

How are events defined?

How are events initiated?

Is there a standard term for an event's invocation (do you say an event "happened", "was called", "was invoked","triggered")?

Where in the block header does an Event end up?

Relevant:

How to implement events in solidity

Where do contract event logs get stored in the Ethereum architecture?

up vote 22 down vote accepted

The blockchain is a list of blocks which are fundamentally lists of transactions. Each transaction has an attached receipt which contains zero or more log entries. Log entries represent the result of events having fired from a smart contract.

In the Solidity source code, to define an event, you mark it thus by preceding it with the event keyword (similar in usage to the function keyword). You then call or fire the event in the body of whatever function you wish to cause to generate the event. (I doubt there is a standard wording for it). You may fire events from any function using the emit keyword.

Someone can probably add information on how to 'listen' for events in your DAPP. It uses the filtering functionality of Web 3.0

Check out the Etheruem Ontology which was recently published by Johannes Pfeffer for a very thourough explanation of many Ethereum concepts.

  • 1
    Is it kind of like the JavaScript event which can be triggered with something happening i.e event based? – Fahad Uddin May 20 at 17:56
  • 1
    Yes. It is. Filler. – Thomas Jay Rush May 20 at 21:44
  • 2
    @FahadUddin In it's most basic form, an event is EXACTLY printing a log. Therefore it is kind of like Javascript's console.log. That's it, nothing more, nothing less. In Solidity it has zero other purpose than logging the event to the blockchain. However, you can listen to events in real-time from outside code so you can use events as a sort of push notification. – slebetman Jun 21 at 3:42

Events are dispatched signals the smart contracts can fire. DApps, or anything connected to Ethereum JSON-RPC API, can listen to these events and act accordingly. Event can be indexed, so that the event history is searchable later.

An example event from a wallet contract is:

event Deposit(address from, uint value);

The application (dapp, web application, other) interested in deposits to a wallet contract would listen to this event. The application would connect to Ethereum node over JSON-RPC and either watch (wait) for the event to happen or read all the past events to sync up the application internal state with Ethereum blockchain.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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