Events are data packets that can be emitted by smart contracts. They work in much the same way as Ethereum events
Once an event is emitted from a smart contract, it is forgotten by the blockchain which can no longer access the event. Instead, the event is logged into the event database.
The event database is a postgreSQL attached to the sharder.
An event takes the following form
There are five searchable fields, plus one data field.
blockNumber: The block number that contains the transaction that emitted the event
txHash: The hash of the transaction that emitted the event.
Type: Information about how the EventDb is to process the event. TypeStats indicates the event contains instructions to modify an Event database table. Other events currently are given no special treatment.
Tag: Further information on the event and how to interpret the data field. Typically indicates what modification to which table. Is the data a marshalled object to be added or the id of a row to be removed?
Index: This is used to identify events. So events are uniquely defined by txhash and Index. So all but one copy of an event are discarded.
Data: Information packet. For example, a json marshalled object to be added to an event database table.
All events are added to an event table, searchable on BlockNumber, TxHash, Type, Tag and Index.
There is a zwallet command events for viewing this database table.