A smart contract is self-executing code deployed on a blockchain. It automatically enforces agreements when specified conditions are met. There are no intermediaries. No one needs to oversee execution. The code runs on the blockchain network itself. Once deployed, it's immutable. It can't be changed. It will execute exactly as written. This is both a feature and a risk.
A feature because the counterparty can trust that the contract will do what it says. A risk because if the code has a bug, that bug executes forever. Smart contracts are how DeFi works. A lending contract automatically lends assets to a user who deposits collateral. It automatically sells the collateral if the price drops below a threshold. It automatically distributes interest to lenders.
No banks. No lawyers. No intermediaries. The contract enforces the agreement. Ethereum made smart contracts programmable. Bitcoin has limited scripting. Ethereum lets you write arbitrary code. This opened a category of applications. Smart contracts power decentralized exchanges, lending protocols, insurance, governance, NFT ownership, and more.
The limitation is that smart contracts can only interact with data on the blockchain. They can't access real-world information directly. They need oracles to bring external data on-chain. Smart contracts are the foundation of DeFi and Web3 infrastructure.