A vending machine follows instructions: the right payment and selection release a snack. A smart contract follows code, with the network checking the result.
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.
A program with an address
A smart contract has code and an address on Ethereum. A user sends it a transaction to request an action. Its functions describe actions that can run, and its storage holds values that persist between calls.
An example: a shared counter
Imagine a counter that starts at zero. Calling increment() adds one. The transaction gives the network an instruction, the code calculates the new value, and everyone can verify the same result. The contract does not need a person to approve each increment if its rules allow anyone to call it.
Code has limits
Contracts do not spontaneously wake up or directly read any website they want. An outside transaction triggers work, and external facts need to be supplied through mechanisms such as oracles. A bug or unsafe permission in the code can still cause harm. Public code is inspectable, not automatically safe.
What developers use
Solidity is one language for writing these programs. An ABI describes the interface, and the EVM executes compiled instructions. Start with the little counter experiment, then move to encoding a real function call in the ABI lab.
QUICK CHECK · NO PRESSURE
What usually triggers a contract to change its state?
Contracts execute as part of transaction processing. They do not run on their own schedule.