โ† Blockchain & Smart Contracts (Solidity) learning path
Blockchain & Smart Contracts (Solidity) ยท Module 4 of 10

Functions, modifiers and events

Control behaviour and emit logs.

๐Ÿ“– Key ideas

  1. view functions read state; pure functions use no state.
  2. payable functions receive ETH.
  3. Modifiers reuse checks: modifier onlyOwner { require(msg.sender == owner); _; }
  4. require/revert reject invalid calls with messages or custom errors.
  5. Events log actions for off-chain apps: emit Transfer(from, to, amount).
๐Ÿ’ก Real-life example: Modifiers are security guards standing in front of functions checking IDs.
viewReads state without modifying
payableCan receive ETH
modifierReusable function condition
eventLog emitted for off-chain listeners