Smart contracts are computer programs that are hosted and executed on a blockchain network. Each smart contract consists of code specifying predetermined conditions that, when met, trigger outcomes. By running on a decentralized blockchain instead of a centralized server, smart contracts allow multiple parties to come to a shared result in an accurate, timely, and tamper-proof manner.
Smart contracts are a powerful infrastructure for automation because they are not controlled by a central administrator and are not vulnerable to single points of attack by malicious entities. When applied to multi-party digital agreements, smart contract applications can reduce counterparty risk, increase efficiency, lower costs, and provide new levels of transparency into processes.
While a general notion of smart contracts could be seen in systems like vending machines (e.g., a specific code leads to an expected snack), blockchains formed the foundation of smart contracts that were digital, tamper-proof, and permissionless. The introduction of the Bitcoin blockchain in 2009 supported arguably the first trustless protocol smart contract.
Example: "Digital will". If funds are held in a Bitcoin address A, a smart contract can be such that, if the address A is not signed even once in 2 years then distribute funds to Bitcoin address B and C. B and C address holders are the beneficiary of funds. This removes middlemen, friction, and unnecessary expenses.