Topic Terms

What is a Smart Contract

A smart contract is self-executing code deployed on a blockchain that automatically enforces the terms of an agreement — running without human intermediaries and forming the foundation of DeFi, NFTs, and decentralized applications.

A smart contract is a program stored and executed on a blockchain that automatically runs pre-defined instructions when specific conditions are met — without requiring a human intermediary to enforce the agreement. The term was coined by computer scientist Nick Szabo in 1994, who imagined a vending machine as an analogy: insert money + select item → vending machine automatically executes the transaction based on coded rules.

Smart contracts are the core technological innovation of Ethereum and are the building blocks of DeFi, NFTs, DAOs, and most decentralized applications (dApps).

How Smart Contracts Work

Smart contracts are deployed to a blockchain where they live at a specific address and execute code when triggered by transactions. Key properties:

  • Deterministic: The same input always produces the same output — there's no discretion or ambiguity
  • Transparent: The code is publicly visible on the blockchain
  • Immutable: Once deployed, the code cannot be changed (though upgradeable contract patterns exist)
  • Trustless: No need to trust a counterparty — the code enforces the agreement
  • Autonomous: Execute automatically when triggered; no human needed to enforce

On Ethereum, smart contracts run on the Ethereum Virtual Machine (EVM) — a sandboxed computing environment replicated across every node in the network.

Simple Example: A Smart Contract Token Sale

Imagine a fundraiser smart contract:

  • If someone sends ETH to this address during the sale period
  • Then automatically send them tokens at the agreed exchange rate
  • Else if the sale period ended and the fundraising goal was not met
  • Then automatically refund all contributions

No company, no employee, no bank is needed — the code executes automatically, and everyone can verify the rules before participating.

What Smart Contracts Power

DeFi protocols: Lending platforms (Aave, Compound), decentralized exchanges (Uniswap), and stablecoins (DAI) are all networks of smart contracts. When you swap tokens on Uniswap, you're interacting directly with smart contract code.

NFTs: Minting, buying, selling, and royalty distribution are governed by smart contracts (ERC-721 and ERC-1155 token standards).

DAOs (Decentralized Autonomous Organizations): Governance is controlled by smart contracts — token holders vote on proposals, and approved changes execute automatically.

Token issuance: ERC-20 (Ethereum's fungible token standard) is a smart contract interface. Every DeFi token — USDC, LINK, AAVE — is an ERC-20 smart contract.

Prediction markets, lotteries, escrow, games: Any agreement where participants want algorithmic enforcement rather than trusting a human intermediary.

Risks and Limitations of Smart Contracts

Code Bugs and Exploits

Smart contracts are only as good as the code. Bugs have led to catastrophic losses:

  • The DAO hack (2016): $60 million in ETH drained through a reentrancy bug — controversial fork of Ethereum was required to recover funds
  • Poly Network (2021): $611 million stolen (subsequently returned) through a signature verification flaw
  • Ronin Bridge (2022): $625 million stolen through compromised validator keys

Smart contract code must be audited by security firms before handling significant value, and even audited code can have unfound vulnerabilities.

The Oracle Problem

Smart contracts can only access data on the blockchain — they cannot natively read real-world information (prices, weather, sports results). Oracles (like Chainlink) bridge this gap by feeding external data on-chain. But oracles introduce their own trust and manipulation risks.

"Code Is Law" and Its Limits

Early crypto ideology held that "code is law" — if a smart contract allows something, it's valid even if unintended. The DAO hack tested this: the hacker argued they had simply used the code as written. The community disagreed and forked the blockchain anyway — highlighting that human judgment doesn't vanish just because code is involved.

Gas Costs

Executing complex smart contract operations on Ethereum requires paying gas fees — sometimes substantially, especially during network congestion.

Smart Contracts vs. Traditional Contracts

Feature Traditional Contract Smart Contract
Enforcement Courts, lawyers, police Automatic code execution
Intermediaries needed Yes No
Flexibility Human interpretation possible Exactly as programmed
Cost Legal fees Gas fees
Speed Days to months Seconds to minutes
Error correction Possible through courts Difficult/impossible post-deployment

Smart contracts are powerful tools for specific use cases with predictable, quantifiable conditions. Complex human agreements (divorce settlements, employment disputes, creative interpretation) remain better suited to traditional legal frameworks.