Skip to content
Reading depth

Each view includes the earlier layers; the complete engineer or auditor page is shown by default.

A smart contract is deployed code and persistent state that applies deterministic rules when a blockchain transaction or another contract calls it.

Hexagon category cue

A smart contract is a program in shared blockchain state that accepts calls and applies its encoded transition rules to assets, claims, and permissions.

Financial arrangements repeatedly test conditions, update balances, enforce limits, and settle between participants. Smart contracts make those rules shared and executable so users and other programs can compose with them. The code narrows some discretionary trust, but it also makes software behavior, configuration, external data, and administrator authority part of the financial contract.

An automated rulebook or transaction agent is a useful analogy. The analogy stops because deployed code follows machine state rather than interpreting legal intent, and public contracts can be called by unknown or adversarial programs in one atomic transaction. Immutable code can be hard to repair; upgradeable code adds a separate controller and change process.

Users and other contracts call the program. Developers define it, deployers initialize it, and administrators or governance may retain powers. Auditors and monitors can inspect behavior but do not guarantee it. Contracts may hold assets or allowances and record shares, debts, withdrawal rights, votes, or conditional entitlements. Those entries are claims only to the extent that the state machine and its dependencies can honor them.

  1. Code and initial state are deployed at an address or behind a governed upgrade mechanism.
  2. A transaction or another contract calls a public function with parameters.
  3. The execution environment evaluates authorization, current state, input, and called dependencies deterministically.
  4. Successful execution commits state changes and events; a revert rolls back the failed call context while still consuming execution resources.
  5. Later calls observe and build on the committed state.

Capital flow follows transfers and approvals. Claim flow follows minted shares, recorded debt, receipts, and redemptions. Information flow enters through calldata, block context, or explicit oracle calls—a contract cannot independently fetch arbitrary off-chain facts. Return flow belongs to the economic mechanism the code implements, not to code itself. Control flow follows roles, upgrade keys, pauses, parameter setters, and external dependencies. Risk flow reaches holders when any assumption breaks.

Smart contracts do not create return from nothing. Borrowers, traders, token issuance, reserve assets, or other counterparties pay any yield. When code creates excess claims, loses assets, blocks exits, or trusts a bad dependency, depositors, liquidity providers, debt holders, token holders, a reserve, or an explicit backstop absorbs the shortfall.

Code is the rule executor, not a promise that the outcome is fair, safe, or legally enforceable. Ask what assets it can move, what claims it records, and who can change its rules.

Inventory addresses, versions, upgrade and pause authority, oracle inputs, token assumptions, parameter bounds, integration dependencies, liquidity, incident procedures, and monitoring. A protocol name is not enough: the active deployment and configuration determine behavior.

On Ethereum, contract code and state live at an address and execute in the EVM when called through transactions or internal messages. Ethereum contracts cannot pull web data by themselves; applications use transactions or oracle systems to place external information on-chain. Other execution environments can use different languages, account models, runtimes, and upgrade patterns.

Review authorization, initialization, state-machine completeness, conservation, solvency, reentrancy, callbacks, unusual tokens, rounding, failure atomicity, upgrades, pauses, and recovery. Testing, audit, and formal verification cover identified code, properties, and assumptions; none should be described as absolute safety.

  • “Smart means intelligent.” A smart contract executes programmed rules; it does not reason about missing context.
  • “Code is law.” Code controls on-chain execution, while legal rights and governance can exist outside it.
  • “Audited means safe.” Review reduces uncertainty within a scope; unknown paths, integrations, configurations, and later upgrades remain.

Read blockchain and transactions and gas first. Continue with settlement and finality before relying on contract results across systems. Review smart-contract risk for failure analysis.

  • Ethereum.org, Introduction to smart contracts — Ethereum contract, state, execution, and off-chain-data boundaries (accessed 2026-08-09).
  • The supplied DeFi seed, sections 2, 7–12, and 14 — programmable primitives, system analysis, and the blockchain stage.

Machine-readable model

Key equations

Canonical expressions come from the structured concept record. KaTeX renders the notation, while the plain-text expression and variable table keep its meaning and units inspectable without JavaScript. Read the narrative above for the model's domain, assumptions, and rounding rules.

This concept does not require one canonical equation. Its mechanism and state transitions remain the authoritative explanation; do not invent a formula merely to make the topic look quantitative.

Assurance contract

Security properties

These structured statements define desired behavior. Their stable IDs can bind tests, invariants, specifications, audit findings, or proof results without turning descriptive review advice into an assurance claim.

Desired · not evaluated: No test, audit, or proof result is implied until scoped evidence is linked to this property.

  1. Every state transition enforces its authorization, preconditions, accounting, and lifecycle rules

  2. External calls and reentrancy cannot expose an unauthorized intermediate or final state

  3. Asset and claim accounting remains conserved under success, revert, and adversarial call ordering

  4. Upgrade, pause, recovery, and administrator powers are explicit, bounded, and observable

Knowledge check

Quiz

Answer in your own words, then open the model answer.

Can a smart contract read a current web price by itself?

Model answer

No. External data must enter through an on-chain transaction or another protocol mechanism such as an oracle, which adds its own trust assumptions.