0Pricing
Web3 & DApp Development Fundamentals · Lesson

Events vs Storage

Gas trade-offs.

Two Ways to Record Data

When something happens in a contract you can record it in storage or in an event log. Choosing wisely is a core gas-optimization skill.

This lesson compares the trade-offs so you know when to use each.

Storage Recap

Storage is the contract's permanent state. It is the only data the contract itself can read back later, but writing to it is very expensive.

<code>mapping(address => uint256) public balances; // contract can read this</code>

All lessons in this course

  1. Declaring Events
  2. Indexed Parameters
  3. Listening for Events
  4. Events vs Storage
← Back to Web3 & DApp Development Fundamentals