Smart Contract
In simple terms
A smart contract is like a vending machine for agreements—you put in money and select an item, and the machine automatically gives you what you paid for without needing anyone to operate it. On blockchain, it's code that automatically executes a deal when all the agreed-upon conditions are met.
Definition
Self-executing code that runs automatically when conditions are met.
In depth
A smart contract is self-executing code deployed on a blockchain that automatically enforces and executes the terms of an agreement when predefined conditions are satisfied. The code runs on a distributed network of validators who reach consensus on its execution through the blockchain's consensus mechanism, ensuring deterministic outcomes. Smart contracts can interact with external data through oracles, trigger transactions, transfer tokens, and maintain state across the ledger. Once deployed, the contract's logic is immutable and transparent, allowing parties to transact without intermediaries while cryptographic hashing ensures the integrity of all state changes.
How does Smart Contract work?
A developer writes the program, compiles it, and sends a transaction that publishes the compiled code to an address on the blockchain. From then on, anyone can call its functions by sending a transaction to that address. Every node runs the same code on the same inputs and must reach the same result, which is what makes the outcome verifiable rather than trusted. The caller pays gas for the computation. If a condition in the code fails, the whole transaction reverts and no balances change, though the gas is still spent. Most contracts cannot be edited once deployed.
An example
An organizer deploys a ticketing contract: send 0.05 ETH and it issues one ticket, capped at 200 tickets. The 200th buyer succeeds. The 201st transaction hits the cap, reverts, and returns that buyer's 0.05 ETH, though the gas is still spent. The contract now holds 200 x 0.05 = 10 ETH, withdrawable only by the address written into the code. Figures are illustrative.
Figures are illustrative only.
What beginners get wrong
- An audit reduces risk without removing it; audited contracts holding large balances are exploited regularly, and an audit is a snapshot of one version of the code.
- Contract outcomes are final. If code moves funds in a way the user did not intend, there is no operator to appeal to and no chargeback.
- Clicking a contract link from a direct message, advertisement, or search result skips the one step that matters: confirming the address against the project's own documentation.
- Many contracts keep an admin key that can pause transfers, change fees, or upgrade the logic, so immutability should be verified rather than assumed.
Related terms
Part of
What is cryptocurrency, and how does it work? — the subject page for cryptocurrency basics, with all 23 of its definitions in one place.
Educational only — not financial advice.
