Events in Smart Contracts
Explore how to define and emit events in Solidity smart contracts to notify Ethereum users of changes in real time. Understand subscribing to events with web3.js and filtering event data. This lesson uses an Auction contract example to demonstrate emitting events and handling blockchain notifications.
We'll cover the following...
In the final lesson, we'll learn about events in Solidity. Events allow notifying Ethereum users in real time about changes with a smart contract. We'll learn how to define events, send them, and subscribe to them programmatically.
Defining events
Before sending an event, we need to define what fields an event contains. Defining an event is similar to defining a struct. We need to use the event keyword, specify the event’s name, and then provide a list of fields each event will have. Event fields provide additional data we can send with each event.