Variables hold values. Functions describe the changes you allow.
LET’S PICTURE IT
A contract is a small rulebook plus a notebook. Functions are the rules; state variables are what it remembers.
SEE IT FOR YOURSELF
A valid counter call, step by stepStep 1 / 4
This example begins with count zero and a request to call increment(). No real contract is deployed.
This example begins with count zero and a request to call increment(). No real contract is deployed.Execution follows the code’s input and permission rules. A website button is not the access-control mechanism.The function reads zero, calculates zero plus one, and writes one to persistent storage.The accepted state contains count one. Later reads can inspect it. Events are emitted only if the code implements them.
Animated local teaching model. No wallet, RPC or live blockchain data. Some labels and hashes are abbreviated for readability.
Start with a counter
A minimal example declares uint256 public count; and a function increment() external { count += 1; }. uint256 is a non-negative integer type. public creates a getter so callers can read count. external means the function is part of the callable interface.
Reads and writes
A view function promises not to modify state through that execution. A pure function does not read or modify contract state. A local read can be simulated without sending a paid transaction. Calling a view function from another onchain transaction still uses execution gas.
Permissions are code
If only an owner should change a setting, the code must enforce that condition. A friendly button or hidden menu is not access control. Anyone can construct calldata and attempt to call an exposed function.
Compilation connects the pieces
The compiler produces bytecode for the EVM and an ABI for applications. Our counter visual is an educational model, not a deployed Solidity compiler. Continue with ABI encoding to see exactly what a function request looks like.
QUICK CHECK · NO PRESSURE
Can hiding a button secure a public function?
People can call the contract without using your interface. Permissions must be enforced by code.