What Is a Smart Contract?
A smart contract is a self-executing program stored on a blockchain that automatically carries out predefined terms when specific conditions are met — without any intermediary. Once deployed, smart contracts run exactly as written and cannot be changed by either party, making them tamper-resistant but also unforgiving of bugs or design flaws.
How Smart Contracts Work
The term "smart contract" was coined by cryptographer Nick Szabo in 1994, long before blockchain technology existed. Szabo imagined a vending machine as an analogy: you insert money, select an item, and the machine automatically dispenses it — no human clerk needed, no trust required beyond the machine itself. Modern smart contracts on blockchains like Ethereum work on this same principle, replacing human enforcement with deterministic computer code. A developer writes the contract's logic in a language like Solidity, deploys it to the blockchain, and from that point the code runs autonomously whenever its trigger conditions are satisfied.
Smart contracts are stored at a specific address on the blockchain and can hold, send, and receive cryptocurrency. When a user interacts with a contract — say, depositing tokens into a DeFi lending protocol — the contract code executes automatically: it records the deposit, tracks the user's balance, calculates accrued interest, and releases collateral when conditions for withdrawal are met. No bank, no escrow agent, no counterparty approval is required. Every action is recorded on-chain, publicly auditable, and mathematically verified by the network's nodes.
The immutability that makes smart contracts trustworthy also makes errors permanent. A bug in a deployed contract cannot be patched the way a web app can be updated — the original code runs forever unless the contract was deliberately designed with an upgrade mechanism. The 2016 DAO hack, in which attackers exploited a reentrancy vulnerability to drain roughly $60 million in Ether, is the canonical lesson: code that cannot be changed is only as reliable as the care taken to write it correctly the first time.
Key Points
- Smart contracts execute automatically when predefined conditions are met, requiring no third-party intermediary to enforce the terms.
- Ethereum is the dominant smart contract platform, but other chains including Solana, Avalanche, and BNB Chain also support smart contracts.
- Once deployed, a smart contract's code is immutable — bugs cannot be patched, which is why security audits before deployment are critical.
- Smart contracts power DeFi protocols, NFT marketplaces, decentralized exchanges, stablecoins, and cross-chain bridges.
Learn More
Smart contracts are the foundation of decentralized finance. See DeFi & Yield Farming for a complete guide to how smart contracts enable lending, borrowing, and earning yield.
Related: Browse all questions
Related Questions
Can smart contracts be hacked? Smart contracts themselves cannot be altered once deployed, but they can contain exploitable bugs in their code. Attackers have drained hundreds of millions of dollars from DeFi protocols by exploiting vulnerabilities such as reentrancy attacks, integer overflows, and logic errors. Reputable protocols undergo professional security audits before launch, but audits are not a guarantee of safety.
What is the difference between Ethereum and Bitcoin? Bitcoin is primarily a decentralized digital currency and store of value with a deliberately limited scripting language. Ethereum is a programmable blockchain platform designed to host smart contracts and decentralized applications (dApps). Ether (ETH) is the native token used to pay for computation on the Ethereum network, while BTC's primary use case is value transfer and storage.