A small state variable and one rule make execution easier to picture.
LET’S PICTURE IT
A classroom tally can remember a number and allow an agreed action to increase it by one.
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 remembered state
Imagine a contract with a stored count of zero. Storage persists between calls, unlike a temporary calculation in one execution. The count is a value associated with this contract’s state.
Define a transition
A function named increment adds one to the count. Calling it twice in accepted successful transactions changes zero to one and then two. Nodes check the specified rule rather than trusting a website’s displayed number.
Read without changing
A getter can report the current count through a read simulation. Reading the value does not itself increment it. The same function name in an interface and an onchain state change are different parts of the system.
Try the local model
The button above changes a browser-only counter according to the same simple rule. It uses no wallet or network. Once the rule makes sense, read about function arguments and how an ABI turns the request into bytes.
QUICK CHECK · NO PRESSURE
Does reading a counter automatically increase it?
A getter reads a value. Only an allowed state-changing operation updates it.