Smart Contract

A smart contract is a self-executing computer program stored on a blockchain that automatically enforces, executes, and verifies the terms of an agreement when predetermined conditions are met, without the need for intermediaries such as lawyers, banks, or notaries. The term was coined by computer scientist Nick Szabo in 1994, who described them as “a set of promises, specified in digital form, including protocols within which the parties perform on these promises.”

On the Ethereum blockchain and other smart contract platforms, smart contracts are written in programming languages like Solidity (Ethereum), Rust (Solana), or Move (Sui, Aptos). Once deployed to the blockchain, the contract’s code is generally immutable; it cannot be changed or tampered with, except in the case of contracts specifically designed with upgradeable proxy patterns. The contract has its own blockchain address, can hold funds, send transactions, and interact with other contracts. When a user or another contract sends a transaction to the smart contract that satisfies its conditions, the code executes automatically, and the results are recorded permanently on the blockchain.

Smart contracts are the foundation of the entire decentralized application (DApp) ecosystem. They power decentralized exchanges (Uniswap), lending protocols (Aave, Compound), decentralized stablecoins (DAI and its newer sibling USDS, issued by Sky Protocol, the 2024 rebrand of MakerDAO), NFT marketplaces (OpenSea), decentralized autonomous organizations (DAOs), and thousands of other applications. Smart contracts have collectively managed tens of billions of dollars in assets across DeFi at any given time, though that figure has proven quite volatile, having peaked near $180 billion in late 2021, fallen to roughly $38 billion in late 2022, and fluctuated in the range of roughly $70 to $140 billion at various points in 2025 and 2026. Even accounting for that volatility, smart contracts have demonstrated transformative potential for finance, governance, supply chains, insurance, and virtually any process that involves conditional logic and value transfer.

Origin & History

1994: Nick Szabo, a computer scientist and legal scholar, coins the term “smart contract” and describes the concept of embedding contractual clauses into hardware and software to make breach of contract expensive for the breaching party.

1998: Szabo designs “Bit Gold,” a decentralized digital currency concept that incorporates smart contract ideas, prefiguring Bitcoin by a decade.

2013: Vitalik Buterin publishes the Ethereum whitepaper, proposing a blockchain with a Turing-complete programming language capable of running arbitrary smart contracts.

2015 (July): Ethereum launches, making smart contracts practically deployable for the first time. The Solidity programming language becomes the standard for writing Ethereum smart contracts.

2016: “The DAO,” a smart contract-based decentralized venture fund, raises roughly $150 million but is exploited due to a reentrancy vulnerability, draining around $60 million worth of ETH at the time. The incident leads to the Ethereum hard fork and becomes a landmark lesson in smart contract security.

2017: The ERC-20 token standard enables anyone to create fungible tokens via smart contracts, helping spawn the ICO boom. Thousands of new tokens are created.

2018: Smart contract security becomes a major focus. OpenZeppelin publishes battle-tested smart contract libraries. Formal verification tools emerge.

2020: DeFi Summer showcases the power of composable smart contracts. Protocols like Uniswap, Compound, and Yearn Finance create complex financial products entirely through smart contract interactions.

2021: NFTs (ERC-721 smart contracts) explode in popularity. Smart contracts power everything from a $69 million digital art sale to play-to-earn gaming economies.

2022 to 2023: Account abstraction (ERC-4337) enables smart contract wallets with improved UX features like social recovery and gasless transactions.

2024 (August): MakerDAO, one of the oldest and most significant DeFi smart contract systems, rebrands as Sky Protocol as part of its Endgame plan. A new stablecoin, USDS, launches alongside the existing DAI at a 1:1 upgrade rate, and the MKR governance token becomes convertible to a new token, SKY, at a fixed 1:24,000 ratio. Both DAI and MKR continue to exist as legacy tokens alongside their newer counterparts.

2024 to 2026: Smart contract platforms mature further, with continued work on formal verification, intent-based architectures, and AI-assisted smart contract auditing. Cross-chain smart contract interoperability improves through messaging protocols. By 2026, USDS has grown to overtake DAI in raw supply, while DAI itself remains a widely used, smaller legacy stablecoin within the same underlying Sky Protocol system.

“A smart contract is a computerized transaction protocol that executes the terms of a contract. The general objectives are to satisfy common contractual conditions, minimize exceptions both malicious and accidental, and minimize the need for trusted intermediaries.” Nick Szabo, 1994.

In Simple Terms

The vending machine: a smart contract is like a vending machine. You put in money and make a selection, and the machine automatically checks the payment, verifies the selection, and dispenses the product. No cashier needed. The “rules” (price list, inventory) are programmed in advance, and the machine executes them without human intervention.

The escrow robot: imagine you’re buying a house. Instead of a lawyer holding the money in escrow, a robot does it. The robot is programmed: “When the deed is transferred to the buyer, release the payment to the seller.” It follows these rules exactly, every time, without bias, delay, or error. That robot is a smart contract.

The unstoppable agreement: a smart contract is like writing an agreement in permanent ink inside a transparent, locked glass box. Everyone can see the terms, nobody can easily change them, and when the conditions are met, the agreement executes itself automatically.

If-then-else, but with money: at its core, a smart contract is a series of “if-then” rules. If Alice sends 1 ETH, then send her 100 tokens. If the price drops below $50, then sell the position. If 3 of 5 signers approve, then release the funds. Simple logic, but with real money and no easy way to cheat.

Important: Smart contracts are only as good as their code. A bug in a smart contract can lead to irreversible loss of funds. In the strict “code is law” sense, there is no customer service to call and no “undo” button for most contracts. Always interact with audited, battle-tested smart contracts, and understand the risks.

Key Technical Features

Immutability and Determinism

  • Once deployed on the blockchain, smart contract code generally cannot be changed, unless it was specifically built with an upgradeable proxy pattern
  • Given the same inputs, a smart contract always produces the same outputs on every node
  • This determinism ensures all network participants agree on execution results
  • Immutability provides a form of trust: users know the rules generally won’t change after they commit funds, apart from contracts explicitly designed to be upgradeable

Solidity Programming Language

  • The dominant smart contract language for Ethereum and EVM-compatible chains
  • Influenced by JavaScript, Python, and C++
  • Key concepts include functions, modifiers, events, state variables, mappings, and structs
  • Security considerations include reentrancy guards, integer overflow protection, and access control patterns
  • Alternative languages include Vyper (a Python-like alternative for Ethereum), Rust (Solana), Move (Sui and Aptos), and Cairo (StarkNet)

Composability (“Money LEGOs”)

  • Smart contracts can call and interact with other smart contracts smoothly
  • A lending contract can interact with a DEX contract, which interacts with an oracle contract
  • This creates a composable ecosystem where new applications can build on existing ones
  • Flash loans demonstrate extreme composability: borrowing, trading, and repaying within a single transaction

Gas and Execution Cost

  • Every smart contract operation costs gas, computational units priced in the native cryptocurrency
  • More complex operations cost more gas; storage operations are typically among the most expensive
  • Gas optimization is a critical skill for smart contract developers
  • EIP-1559 introduced a base fee mechanism on Ethereum for more predictable gas pricing

Events and Logging

  • Smart contracts emit events that off-chain applications can listen to
  • Events are stored in transaction logs rather than in contract storage, making them cheaper to write
  • Used by front-end applications (DApp interfaces) to track contract activity in near real time
  • Essential for building responsive user interfaces for DeFi protocols, NFT platforms, and similar applications

Advantages & Disadvantages

AdvantagesDisadvantages
Trustless execution: No need to trust a middleman; code enforces the rulesImmutable bugs: If the code has a bug, it generally cannot be easily fixed after deployment
Transparency: Anyone can read and verify the contract code on the blockchainComplexity: Writing secure smart contracts requires specialized expertise
Automation: Executes automatically when conditions are met, around the clockOracle dependency: Smart contracts cannot access off-chain data without oracles
Cost reduction: Reduces reliance on intermediaries like lawyers, brokers, and escrow agentsGas costs: Execution fees can be high on congested networks
Composability: Contracts can interact with each other to build complex systemsIrreversibility: Mistakes in transactions or contract interactions generally cannot be undone
Global access: Anyone with an internet connection can interact with smart contractsScalability: Complex contract interactions can be slow and expensive on base layer blockchains
Censorship resistance: No single entity can typically prevent a valid smart contract from executingLegal ambiguity: Smart contracts don’t yet have fully settled legal standing in most jurisdictions

Risk Management

Smart Contract Vulnerabilities:

  • Reentrancy attacks: When a contract calls an external contract before updating its own state, allowing the external contract to “re-enter” and drain funds. The DAO hack, which drained roughly $60 million worth of ETH, was caused by this
  • Integer overflow/underflow: Arithmetic errors that were more common in older Solidity versions. Modern Solidity (0.8 and later) has built-in overflow protection
  • Front-running: Miners or validators can see pending transactions and insert their own transactions ahead of them, extracting value (MEV)
  • Access control errors: Forgetting to restrict who can call critical functions, allowing anyone to drain funds or change parameters

Security Best Practices:

  • Always use audited contracts from reputable projects; check for multiple audits from independent firms
  • Review audit reports; an audit doesn’t guarantee safety, but it reduces risk significantly
  • Start with small amounts when interacting with new contracts
  • Revoke unnecessary token approvals using tools like Revoke.cash or a block explorer’s token approval checker
  • Use established libraries (such as OpenZeppelin) rather than writing security-critical code from scratch

Governance Risk:

  • Upgradeable smart contracts can be changed by admin keys; check who holds these keys
  • Time-locks on admin functions give users time to exit before changes take effect
  • Multi-sig requirements for admin actions reduce the risk of a single compromised key
  • DAOs can vote to change contract parameters; understand the governance structure before depositing funds

Cultural Relevance

Smart contracts represent a major shift in how humans create and enforce agreements. The crypto community’s mantra “code is law” captures the philosophy that software rules, not human judgment, should govern digital interactions. This creates a more predictable, fair, and accessible system, but also raises challenging questions about what happens when code produces unintended outcomes.

The DAO hack of 2016 remains a defining cultural moment for smart contracts. When roughly $60 million was drained through a code vulnerability, the Ethereum community faced a moral dilemma: the code had executed exactly as written (the “exploit” was technically a valid interaction with the contract), but the outcome was clearly not the intended one. The controversial decision to hard fork Ethereum to reverse the hack established a precedent that continues to inform debates about immutability, governance, and the limits of “code is law.”

“Smart contracts sound great in theory, but they’re only as smart as the people who write them.” A common saying in the developer community.

The annual Ethereum hackathon circuit (ETHGlobal, ETHDenver) and smart contract auditing competitions (Code4rena, Sherlock) have created a vibrant culture of building, breaking, and securing smart contracts.

Real-World Examples

1. Uniswap, Automated Market Maker

Uniswap is a smart contract protocol that enables anyone to trade tokens without an order book or centralized exchange. Its core smart contract uses a mathematical formula (x times y equals k) to automatically price trades based on supply and demand in liquidity pools. Well over $2 trillion in cumulative volume has been traded through Uniswap’s smart contracts over its history, all without a single employee processing any individual trade.

2. Sky Protocol (formerly MakerDAO), Decentralized Stablecoins

Sky Protocol, known as MakerDAO until its August 2024 rebrand, uses smart contracts to create and manage decentralized stablecoins. Users lock collateral (such as ETH, BTC, or other approved assets) into smart contract “vaults” and mint DAI, or its newer sibling USDS, against it. If the collateral value drops below a required threshold, the smart contract automatically triggers liquidation of the position to protect the system. As of 2026, USDS has grown to a larger supply than DAI, with the two stablecoins together representing well over $10 billion in circulating value backed by the same underlying vault system, while the MKR governance token continues migrating toward its SKY successor at a fixed 1:24,000 ratio.

3. Chainlink, Decentralized Oracles

Chainlink’s smart contracts connect blockchains to real-world data, such as prices, weather, and sports scores. When a DeFi protocol needs the current price of ETH, Chainlink’s oracle network aggregates data from multiple sources and delivers it to the requesting smart contract. Reported figures for the value Chainlink secures across DeFi and its cross-chain infrastructure vary considerably by methodology and by whether cross-chain messaging volume is included, with some measures placing the figure well above $100 billion and others, focused narrowly on DeFi price feeds, in the tens of billions.

Comparison Table

FeatureSmart ContractTraditional ContractAPI/Web Service
EnforcementAutomatic (code)Manual (courts/lawyers)Automatic (server)
Trust ModelTrustless (blockchain consensus)Trust-based (legal system)Trust in the provider
TransparencyFully public and verifiablePrivate between partiesProprietary/closed
ModificationImmutable, or governance-controlled if designed to be upgradeableAmendable by agreementProvider can change at any time
UptimeContinuous (decentralized)Business hours (courts)Typically around 99.9% (centralized)
CostGas fees per transactionLegal fees, court costsAPI subscription fees
SpeedSeconds to minutesDays to yearsMilliseconds
JurisdictionGlobal (borderless)Jurisdiction-specificGoverned by the provider’s terms of service

Related Terms

FAQ

Q: What programming language are smart contracts written in? The most popular language is Solidity, used for Ethereum and EVM-compatible chains. Other languages include Vyper (a Python-like alternative for Ethereum), Rust (used for Solana programs), Move (used for Sui and Aptos), Cairo (used for StarkNet), and Clarity (used for Stacks and Bitcoin). Solidity remains by far the most widely used, with the largest developer community and tooling ecosystem.

Q: Can smart contracts be changed after deployment? Standard smart contracts are immutable; once deployed, the code generally cannot be changed. However, “upgradeable” smart contracts use a proxy pattern where the logic contract can be swapped out while maintaining the same address and state. This introduces a trust assumption: whoever controls the upgrade keys can change the contract’s behavior. Many DeFi protocols use timelocks and multi-sig wallets to mitigate this risk.

Q: Are smart contracts legally binding? The legal status of smart contracts varies by jurisdiction and is still evolving. Some US states, including Arizona and Tennessee, have passed laws recognizing smart contracts. The UK Law Commission has stated that smart contracts can form binding legal contracts. However, in most jurisdictions, legal enforceability still depends on whether traditional contract law requirements (offer, acceptance, consideration, intent) are met, regardless of the medium.

Q: What happens if a smart contract has a bug? If a smart contract has a bug, there is generally no way to “fix” it after deployment unless it uses an upgradeable pattern. Bugs can lead to permanent loss of funds. This is why smart contract auditing is critical; professional auditors review the code for vulnerabilities before deployment. Bug bounty programs incentivize white-hat hackers to find vulnerabilities, and insurance protocols like Nexus Mutual offer coverage against certain smart contract failures.

Q: How much does it cost to deploy a smart contract? The cost varies significantly by blockchain and by current network conditions. On Ethereum mainnet, deploying a simple smart contract can cost anywhere from tens to several hundred dollars or more, depending on gas prices and contract complexity. On Layer 2 networks (Arbitrum, Optimism, Base), costs are typically a small fraction of that. On Solana, deployment costs are usually well under a dollar. More complex contracts, such as a full DeFi protocol, generally cost more because they contain more code that requires more gas to store on-chain.

Sources

  • Szabo, N., “Formalizing and Securing Relationships on Public Networks,” First Monday, 1997
  • Ethereum Foundation, “Introduction to Smart Contracts,” ethereum.org
  • OpenZeppelin, “Smart Contract Security Best Practices,” docs.openzeppelin.com
  • Trail of Bits, “Building Secure Smart Contracts,” github.com/crytic
  • Atzei, N. et al., “A Survey of Attacks on Ethereum Smart Contracts,” eprint.iacr.org, 2017
  • Sky Protocol (formerly MakerDAO) documentation and rebrand announcement, 2024

Latest Resources and Blogs