1. How are events declared?
Events are declared using the event keyword, such as event [name of event] (param1 of event to be logged, param 2 of event to be logged, …)
They need to be declared outside a function, their name must be different from a function names, they should be written in CapWords as per Solidity style guide,
2. How can we emit events?
Events are emitted by using them in the body of a function. An example below:
contract C {
event EventSendCoin(address indexed sender, address indexed receiver, uint256 amount);
function sendCoin(address receiver, uint amount) returns (bool sufficient) {
// ...
EventSendCoin(msg.sender, receiver, amount);
return true;
}
}
3. How and where do we listen for events?
Events can be accessed from an external application, using the RPC interface of an ETH client, such as a Dapp. Events cannot be accessed within a smart contract, not even the smart contracts that created them.