Functions and Visibility 👁️
Functions are how your contract interacts with the world. They define what your contract can do, from returning a score to updating a record.
Solidity uses Visibility Levels to decide who can call a function:
public: Anyone can call it.
external: Only callable from outside the contract.
internal: Only this contract or its children can call it.
private: Only this specific contract has access.
Nice! Remember: Writing to storage is the most expensive thing you can do on-chain. Smart developers optimize their logic to keep gas costs low.
If a function only reads data, mark it as view. If it doesn't even read from storage (maybe it just does math), mark it as pure.
Think of a view function like...
checking the time on your watch—it's free and fast!
Join our Telegram