Smart Contract
Definition
Self-executing code deployed on a blockchain that automatically enforces the terms of an agreement when predetermined conditions are met, without requiring intermediaries.
Smart contracts are programs stored on a blockchain that execute automatically when conditions are met. They eliminate the need for trusted intermediaries by encoding the rules of an agreement directly into code. Once deployed, the code runs exactly as written — it can't be altered, paused, or censored by any single party.
Ethereum introduced smart contracts in 2015, and they remain the foundation of the DeFi ecosystem. When you swap tokens on Uniswap, take a loan on Aave, or mint an NFT, you're interacting with smart contracts that handle the logic, hold the assets, and enforce the rules.
Smart contracts enable complex financial instruments that previously required banks, lawyers, and intermediaries. Lending protocols automatically liquidate undercollateralized positions. Insurance protocols automatically pay claims based on oracle data. Prediction markets automatically settle based on real-world outcomes.
The security model is fundamentally different from traditional software. Smart contracts handle real money and are immutable once deployed. A bug in a smart contract can lead to permanent loss of funds, as seen in numerous hacks: The DAO ($60M, 2016), Wormhole ($320M, 2022), and others. This is why smart contract audits, formal verification, and battle-testing with real value are critical.
For users, smart contract interaction creates blockchain transactions that are recorded permanently. Each interaction (swap, stake, approve, claim) is a traceable event that may have tax implications. Understanding which smart contracts you've interacted with is important for both security (revoking approvals) and tax reporting.
Where this appears in Clarity
Clarity automatically tracks and calculates these concepts across your connected accounts.
Related Terms
Frequently Asked Questions
Can smart contracts be hacked?
Yes — smart contract bugs and vulnerabilities have led to billions in losses. Common vulnerabilities include reentrancy attacks, oracle manipulation, and logic errors. Using audited, battle-tested protocols with significant TVL reduces (but doesn't eliminate) this risk.
Do I need to understand code to use smart contracts?
No. DeFi applications provide user-friendly interfaces that interact with smart contracts behind the scenes. When you swap tokens on Uniswap, you're using a smart contract without seeing the code. However, understanding what the smart contract does helps you assess the risks.
