What is a Smart Contract? Complete Guide
A smart contract is self-executing code on a blockchain that automatically enforces the terms of an agreement when predefined conditions are met.
What is a Smart Contract?
A smart contract is self-executing code stored on a blockchain that automatically enforces the terms of an agreement when predefined conditions are met. Unlike traditional contracts that require lawyers, courts, or trusted intermediaries to enforce, smart contracts execute deterministically based on their code — "code is law" in the colloquial framing.
Smart contracts are the foundation of most innovation in modern crypto. DeFi protocols, NFT collections, DAOs, stablecoins, and bridging infrastructure all run on smart contracts. Ethereum pioneered general-purpose smart contracts and remains the dominant platform, though Solana, Avalanche, Sui, and many other chains now support sophisticated smart contract programming.
How Does It Work?
Smart contract execution follows a clear pattern:
1. Development: Developers write smart contracts in languages like Solidity (Ethereum), Move (Sui, Aptos), or Rust (Solana). 2. Compilation: Source code compiles to bytecode that the blockchain's virtual machine can execute. 3. Deployment: The bytecode is broadcast in a transaction; once mined, the contract has a permanent address. 4. Interaction: Users send transactions to the contract address, triggering specific functions. 5. Execution: All nodes execute the contract logic deterministically and update state. 6. Result: Contract state changes are stored permanently on-chain.
A simple smart contract might enforce: "If 10 ETH is deposited by address A by Friday, transfer 1,000 USDC to address B." More complex contracts implement entire financial systems, governance protocols, or game economies.
History and Evolution
The term "smart contract" was coined by Nick Szabo in 1994, more than a decade before blockchain technology made them practical. Bitcoin's scripting language (Script) introduced limited smart contract capabilities — multisig, time locks, payment channels — but was intentionally restricted.
Ethereum, launched in 2015 by Vitalik Buterin and co-founders, introduced general-purpose Turing-complete smart contracts with the Ethereum Virtual Machine (EVM). This unleashed an unprecedented wave of innovation: ICOs in 2017, DeFi in 2020-2021, NFTs in 2021, and Layer 2 scaling solutions throughout the period.
Major smart contract platforms by 2024-2025 include Ethereum (dominant), Solana, BNB Chain, Avalanche, Tron, Sui, Aptos, and dozens of EVM-compatible chains. Each makes different trade-offs between performance, decentralization, and tooling.
The discipline of smart contract security has matured significantly. After early disasters like The DAO hack (2016, $50M lost) and the Parity multisig bug (2017, $150M frozen), security standards now include formal verification, professional audits, bug bounties, and battle-testing through gradual TVL ramps.
Key Concepts
- Solidity: The dominant smart contract language, designed for Ethereum. - EVM (Ethereum Virtual Machine): The runtime executing Ethereum smart contracts. - Gas: The unit measuring computational cost of smart contract execution. - Audit: Professional security review of smart contract code. - Reentrancy: A common vulnerability where attackers recursively call functions to drain funds.
Practical Example
A developer creates a simple lending smart contract: users deposit ETH as collateral and can borrow USDC against it at a 50% loan-to-value ratio. The contract enforces:
1. When a user deposits 10 ETH (worth $30,000), they can borrow up to $15,000 USDC. 2. If their collateral value drops below 110% of their loan (e.g., ETH falls 25%), anyone can call the liquidate function. 3. Liquidators receive a 5% bonus from the collateral.
After deployment, the contract operates 24/7 with no human intervention. Thousands of users globally interact with it, billions of dollars flow through it, and its rules execute exactly as coded — for better or worse. This deterministic execution is the essence of what makes smart contracts both powerful and dangerous.