In this track: Meet smart contracts
beginner · 3 MIN READ

Why bugs can be expensive

Public execution can apply an unintended rule just as faithfully as an intended one.

LET’S PICTURE IT

A vending machine that returns the payment and the snack every time is following its faulty program, even when the owner wishes otherwise.

SEE IT FOR YOURSELF
A valid counter call, step by stepStep 1 / 4
A valid counter call, step by stepFunction requestincrement()No argumentsBefore executionstored count0A local teaching example with a defined starting stateIncoming callCheck function dispatchCheck coded conditionsRules passConditions passContinue executionA failed check can revert insteadCalculation0 + 1Result: 1Storage writecount = 1Persists if call succeedsCalculating a local value and storing it are separate stepsPersistent statecount1Later readGetter reports 1No new incrementState, logs and browser display have different roles

This example begins with count zero and a request to call increment(). No real contract is deployed.

Animated local teaching model. No wallet, RPC or live blockchain data. Some labels and hashes are abbreviated for readability.

The machine follows code

A contract bug can let a caller perform actions the author did not intend. The network checks protocol-valid execution, not whether the developer feels happy about the outcome. Correctly executing buggy logic can still cause harm.

Assets and permissions can be affected

An arithmetic error, missing access check or unsafe call sequence may change balances, control or availability. The consequences depend on the implementation and how it is used, not simply on how many lines the contract contains.

Repair may not undo the history

An upgradeable application may have some repair path, but that does not necessarily recover already moved assets or reverse completed actions. An immutable design may have even fewer options to change its behavior.

Testing supports precise claims

Tests, review and formal methods can examine particular properties and assumptions. None is a universal safety badge. Begin by identifying what the contract must preserve, then check the code paths that could violate it.

QUICK CHECK · NO PRESSURE

Will Ethereum reject a protocol-valid transaction merely because it exploits an application bug?

Your progress stays in this browser.
Keep exploring the original referenceethereum.org ↗

Original explanations by EtherTools. Examples are educational and source-linked; this site is independent of the Ethereum Foundation. Our approach.