A smart contract is a program stored on a blockchain that runs automatically when its conditions are met, without needing a middleman to enforce it. "If this happens, then do that" is written directly into code that every participant can verify and that executes exactly as written.
This is what turns a blockchain from a simple ledger into a platform. Smart contracts underpin decentralised finance, token issuance and much else — replacing the role a bank, broker or escrow agent would traditionally play with self-executing code.
The flip side is that code is law, bugs included. A flaw in a smart contract can be exploited to drain funds, and because transactions are irreversible there is often no undo. "Trustless" shifts trust from an institution to the correctness of the code and those who wrote it.
Worked example
A smart contract can automatically swap one token for another the instant a user's funds arrive, with no exchange acting as middleman.
This definition is general education, not investment advice. Markets — especially crypto — are volatile and you can lose money. Please read our disclaimer and see our methodology.