Bitcoin is the first and best-known blockchain but is also quite limited since it offers little beyond the ability to process and record cryptocurrency transactions, although it is increasingly being used for NFTs and other basic programming. This helps explain the popularity of later blockchains like Ethereum, which offers more complex smart contracts.
Smart contracts bring blockchains to life by letting users create and run on-chain programs, like decentralized finance and NFTs.
A smart contract is composed of functions (“if X, do Y”) and data (like NFTs). Nick Szabo, a cryptographer and one of the first people to receive Bitcoin, coined the term in 1997. He likened the logic of a smart contract to that of a vending machine.
Smart contracts are pieces of code that define the rules of on-chain interactions and enforce the rules encoded within them. Once a developer deploys a smart contract on the blockchain, it cannot be deleted, and any interaction is irreversible.
These contracts facilitate complex blockchain functions, like lending. For instance, when a user locks up a certain amount of ETH as collateral, MakerDAO’s smart contract will let them mint a certain amount of Dai. All this takes place without intermediaries, pre-programmed according to the rules baked into the smart contract.
Smart contracts are written in specialist coding languages, like Solidity and Vyper. Anyone can deploy one on a permissionless blockchain, like Ethereum, and anyone can interact with the contract.
Smart contracts often rely on “oracles,” which are programs that retrieve external data from the wider internet. Smart contracts execute pre-defined functions once they receive certain information from oracles, such as cryptocurrency prices.
Ethereum is the largest blockchain to support smart contracts. It is followed from some distance by Tron and Binance Smart Chain (BSC).
While the Bitcoin (BTC) blockchain doesn’t currently support smart contracts, a project called Stacks wants to change that by building a supporting blockchain, known as a sidechain, that works with Bitcoin. Bitcoin hardliners argue that the blockchain should only be used in its most basic form: for storing and transferring value.
Go deeper:
Clean Contracts—a guide on smart contract patterns & practices—Wesley Van Heije, Ethereum Foundation
Best Practices for Smart Contract Development—Yos Riady, a Solidity developer
See also:
What are blockchains?
What is Ethereum?
Try it:
OpenZeppelin—an open-source library for smart contracts