โ Blockchain & Smart Contracts (Solidity) learning pathBlockchain & Smart Contracts (Solidity) ยท Module 4 of 10
Functions, modifiers and events
Control behaviour and emit logs.
๐ Key ideas
- view functions read state; pure functions use no state.
- payable functions receive ETH.
- Modifiers reuse checks: modifier onlyOwner { require(msg.sender == owner); _; }
- require/revert reject invalid calls with messages or custom errors.
- 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