1.How are events declared?
Events are declares by using the keyword event;
Events are defined within the contracts as global and called within its functions.
followed by an identifier and the parameter list.
The parameter values are used to log the info and are saved as part of the transactions inside the block.
2.How can we emit events?
We use emit
keyword, followed by the name of the event and the arguments in paranthesis.
emit EventName(); to call events explicitly.
3.How and where do we listen for events?
three parameters with the indexed attribute make a structure known as ātopicsā. These topics allow you
to search for events by the address of the contract that emitted the event.
A place we can listen for events is when filtering a sequence of blocks for certain events. Filter by
address of the contract that emitted the event.
*Listening for events have to be implemented on a service outside of the blockchain which forwards events to the contract. =====>>> like through a front-end app/
BUT a contract cannot listen to events.