In this short tutorial, I would like to show you the basics of events in Solidity. Specifically, I will explain what are the events in solidity and how to use them in our smart contract. What are the events? Following the Solidity documentation: “ ” Events are inheritable members of contracts. When you call them, they cause the arguments to be stored in the transaction’s log — a special data structure in the blockchain. These logs are associated with the address of the contract, are incorporated into the blockchain, and stay there as long as a block is accessible Why do we need events? Events are used to inform external users that something happened on the blockchain. Smart contracts themselves cannot listen to any events. All information in the blockchain is public and any actions can be found by looking into the transactions close enough but events are a shortcut to ease the development of outside systems in cooperation with smart contracts. How to use events in Solidity Solidity with the event keyword. After events are called, their arguments are placed in the blockchain. To use events first, you need to declare them in the following way: defines events event moneySent(address _from, _to, uint _amount); address The definition of the event contains the name of the event and the parameters you want to save when you trigger the event. Then you need to emit your event within the function: emit money ; Sent( . , , ) msg sender _to _amount Solidity events are with Ethereum Virtual Machine logging functionality. You can an attribute indexed to up to three parameters. When parameters do not have the attribute, they are ABI-encoded into the data portion of the log. interfaces add indexed To better understand the event let’s see the full code. pragma solidity ^ . ; contract MyContract{ mapping(address => uint) public Balance; event moneySent(address , address , uint ); constructor public { = msg.sender; moneyBalance[msg.sender] = ; } function sendMoney(address , uint ) public returns(bool) { require(msg.sender = ; ); require(Balance[msg.sender] >= ; ); moneyBalance[msg.sender] -= ; moneyBalance[ ] += ; emit moneySent(msg.sender, , ); return ; } //SPDX-License-Identifier: MIT 0.8 4 _from _to _amount owner 50 _to _amount owner "You are not allowe" _amount "Not enough money" _amount _to _amount _to _amount true Takeaways There are two types of Solidity event parameters: indexed and not indexed, Events are used for return values from the transaction and as a cheap data storage, Blockchain keeps event parameters in transaction logsEvents can be filtered and by name by contract address References https://docs.soliditylang.org/en/v0.8.4/ https://www.geeksforgeeks.org/what-are-events-in-solidity/ https://www.bitdegree.org/learn/solidity-events https://ethereum.stackexchange.com/questions/56879/can-anyone-explain-what-is-the-main-purpose-of-events-in-solidity-and-when-to-us