Essential events – EVM logger
EVM provides logging facilities through events. When events are called, the arguments that are passed along with them will be stored in the transaction log. This also helps listeners in the distributed application to trigger an action based on a transaction. These logs are associated with the address of the respective contract. The contract itself cannot access any log information stored in the transaction.
In this recipe, you will learn about logging and events, and listening to them from the JavaScript console of geth
.
Getting ready
You will need a working installation of geth
to test the event listener scripts given in this tutorial. Commands starting with >
are executed from the geth
JavaScript console.
How to do it...
Follow these steps to create and emit events from the contract:
- Events are declared with the event keyword. The following example creates an event with three parameters:
event Transfer( address _from, address _to, uint _value );
- Events...