Smart Contract
A smart contract is a self-executing agreement with the terms directly written into lines of code, residing on a blockchain and automatically enforced.
Conceptually introduced by Nick Szabo in the mid-1990s, smart contracts represent the logic layer of the programmable blockchain. They serve as the foundation for Decentralized Finance (DeFi), NFTs, and DAOs, enabling trustless coordination across global networks.
graph LR
Center["Smart Contract"]:::main
Rel_decentralization["decentralization"]:::related -.-> Center
click Rel_decentralization "/terms/decentralization"
Rel_decentralized_exchange_dex_order_book_aggregation["decentralized-exchange-dex-order-book-aggregation"]:::related -.-> Center
click Rel_decentralized_exchange_dex_order_book_aggregation "/terms/decentralized-exchange-dex-order-book-aggregation"
Rel_flash_loan["flash-loan"]:::related -.-> Center
click Rel_flash_loan "/terms/flash-loan"
classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
linkStyle default stroke:#4b5563,stroke-width:2px;
🧒 Explain Like I'm 5
🤖 Think of a smart contract like a high-tech vending machine. You put in the correct coins (data/payment), and you get exactly what you asked for (a product/service) automatically. There's no store clerk to argue with; the machine just follows the rules written in its mechanical (or digital) heart.
🤓 Expert Deep Dive
On the Ethereum Virtual Machine (EVM), smart contracts are compiled into bytecode and executed via state-transition functions. A critical technical property is Deterministic Execution: every node in the network must arrive at the same state given the same inputs. Immutability prevents unauthorized changes post-deployment, though patterns like Proxies and Diamond Standards (EIP-2535) allow for logic upgrades via state redirection. Advanced security utilizes Formal Verification—a process of using formal logic to prove that a contract's code matches its intended specification, neutralizing vulnerabilities like Reentrancy.