Roadmap › Solidity & Smart Contract Development › Module: Language Basics
Lessons in this course (11)

2. Functions: visibility, state mutability and modifiers

Basic★ Must knowLesson 2 of 11
VisibilityCallable from
publicAnywhere (internally and externally); public state vars get getters
externalOnly from outside (other contracts/EOAs), or this.f()
internalThis contract and derived contracts (default for state variables)
privateOnly this contract (still visible on-chain — not secret!)
MutabilityMeaning
(none)Can read and modify state
viewReads state, doesn't modify
pureNeither reads nor modifies state
payableCan receive Ether
solidity
function quote(uint256 qty) public view returns (uint256 price) { price = qty * unitPrice; }
function add(uint256 a, uint256 b) external pure returns (uint256) { return a + b; }

receive() external payable { }                       // plain Ether transfers (empty calldata)
fallback() external payable { }                      // unknown function selector (or Ether with data)

Modifiers wrap function logic (access control, state checks, reentrancy guard). Function overloading is allowed. Calls to view/pure functions from off-chain (eth_call) are free; when called inside a transaction they still cost gas.