Building with Solidity

4. Signaling the Frontend

Implement events to communicate contract activity to external applications.

Prerequisites

Events—The Real-Time Signal 📡

Contracts can't talk to the outside world directly, so they use Events. Think of events as "console logs" that are stored on-chain forever for external tools to see.

Apps like block explorers or your own frontend use these logs to track what is happening in real time.

You trigger these with the emit keyword. Using indexed parameters in your event makes it much easier for tools to search and filter the logs.

In JavaScript, this means...

your app can use WebSockets to "listen" for these signals and update the screen instantly when a user takes an action.

Nice! Events are cheaper than storing data in variables, making them a great way to record history.