Chapter 6

Functions and Modifiers

Functions are how users and other contracts interact with a smart contract. A good beginner habit is to read each function in terms of who can call it and what conditions must be true before it runs.

Visibility keywords answer a practical question: who gets to reach this code path? Modifiers answer the next question: what must already be true before the function body is allowed to continue?

This matters because many contract bugs are really access-control bugs. A mint function with the wrong visibility or a missing modifier can turn a private admin action into a public exploit.