A smart contract is self-executing code deployed on a blockchain. It enforces an agreement when the stated conditions are met. There is no clerk watching execution. The network runs the code. Once deployed, the bytecode is immutable. It cannot be patched in place. It will run exactly as written. That is useful because a counterparty can trust the contract to do what the code says.
It is also a risk. If the code has a bug, that bug runs forever.
DeFi is built from these contracts. A lending contract lends to a user who posts collateral. It sells the collateral if the price falls below a threshold. It pays interest to lenders. No bank, lawyer, or operator sits in the middle. Ethereum made this programmable. Bitcoin has limited scripting. Ethereum lets you write arbitrary logic, which opened a class of applications.
Smart contracts power decentralized exchanges, lending, insurance, governance, NFT ownership, and more. A hard limit is that they can only read data already on the chain. They cannot fetch weather, prices, or scores by themselves. They need oracles for that. Smart contracts are the base layer of DeFi and Web3 infrastructure. It automatically enforces agreements when specified conditions are met.
There are no intermediaries. Ethereum's docs define a smart contract as a program on the blockchain. Nick Szabo coined the phrase in the 1990s. Ethereum made it a live platform in 2015.
Smart Contract
Self-executing code: IF condition met THEN transfer funds.