Smart Contract
۱۴۰۵/۱/۲۷
Smart contract is a program stored on a blockchain that executes automatically when predefined conditions are met. The contract's terms are written directly in code and enforced by the network's consensus — no intermediary, court, or custodian is needed for the contract to run.
How it works
- A developer writes the contract's logic (e.g., in Solidity for Ethereum)
- The code is compiled to bytecode and deployed to the blockchain at a unique address
- Users call the contract by sending transactions; each call runs the code on every node
- The contract's state (storage) is updated deterministically and recorded on-chain
Once deployed, a smart contract is typically immutable — its code cannot be changed, though many contracts include upgrade patterns or admin roles for controlled evolution.
Ethereum and the EVM
Ethereum introduced general-purpose smart contracts in 2015. Its execution environment, the Ethereum Virtual Machine (EVM), has become an industry standard — many other chains (BNB Chain, Polygon, Avalanche, Arbitrum) are EVM-compatible, meaning they can run the same contracts.
Use cases
- DeFi — decentralized exchanges, lending protocols, stablecoins
- NFTs — ownership of digital collectibles and media
- DAOs — on-chain governance and treasury management
- Gaming — in-game assets, rewards, marketplaces
- Identity and oracles — on-chain credentials and external data feeds
Risks
Because contracts are immutable and handle real value, security audits are critical. High-profile hacks (The DAO in 2016, countless DeFi exploits since) have cost users billions. A bug in smart contract code can be permanently exploitable until funds are drained.
