A smart contract is a program stored on a blockchain that runs automatically when its predefined conditions are met, without needing a person or company to execute it manually. They're the foundation of most applications built on \[pillar hyperlink: What Is Ethereum\].

Definition

A smart contract is code deployed to a blockchain that enforces an agreement's terms automatically. Once deployed, it runs exactly as written and can't be altered by any single party, including its creator, unless that ability was explicitly built in.

How they execute

When a transaction calls a smart contract, every node on the network runs the same code and reaches the same result, then updates the shared ledger accordingly. This is what lets a contract function without a trusted intermediary.

Examples

A simple example is a decentralized lending app that automatically releases collateral once a loan is repaid, no bank employee involved. Smart contracts also power token standards like Coins vs Tokens, NFT marketplaces, and \[pillar hyperlink: What Is DeFi\] applications broadly.

Limitations

Smart contracts only do exactly what their code says. Bugs or oversights in that code can be exploited, and mistakes are often irreversible once deployed. They also can't independently verify real-world facts without external data feeds, which introduces its own trust question.