What is a smart contract?
- Author
- CRYPTO PORT Editorial
- Published
- Updated
- Reading time
- 5 min
In short
A smart contract is a program deployed on a blockchain that runs automatically when its conditions are met. It enforces terms without an intermediary — but its code is public, and a bug in it can drain funds directly. DeFi and NFTs are both built on this.
Key points
- Code that executes automatically once conditions are met
- Deployed code is public and anyone can inspect it
- Often immutable once deployed
- Every execution costs gas
Definition
A program stored on a blockchain that executes according to its predefined conditions, with its results recorded on the ledger.
Say the rule is 'if A sends 100 dollars' worth of assets, transfer B's NFT to A'. Neither party has to trust the other: the terms live on-chain as code, and no one can back out mid-transaction.
On Ethereum they are usually written in Solidity and get an address once deployed. Users invoke them by sending a transaction to that address — a DEX swap, a lending deposit and an NFT mint are all such calls.
The crucial point is that a contract does exactly what it says, not what its author meant. 'That wasn't the intent' carries no weight. Bugs in the ordering of transfers have been exploited for losses running into the hundreds of millions of dollars, including in contracts that had been audited.
Watch out for
- · An audit is a point-in-time review, not a safety guarantee
- · Token approvals stay live until you explicitly revoke them
- · Watch for lookalike sites pointing at malicious contract addresses