A smart contract is a self-executing computer program stored on a blockchain that automatically runs when predetermined conditions are met. The terms of an agreement between parties are written directly into lines of code, and because this code exists across a distributed, decentralized blockchain network, the process automates the execution of an agreement and allows all participants to be certain of the outcome without the involvement of an intermediary. Once completed, the transactions are trackable and irreversible. [2][5][1]
Smart contracts seek to reduce dependence on trusted intermediaries, lower arbitration costs and fraud losses, and minimize both malicious and accidental exceptions. Linked closely with cryptocurrencies, smart contracts serve as the foundational building blocks for Web3 applications, including decentralized finance (DeFi) and non-fungible token (NFT) applications. [1][2]
The concept and term "smart contract" were first introduced in 1994 by American computer scientist Nick Szabo, who defined it as “a computerized transaction protocol that executes the terms of a contract.” [1][2] In 1998, Szabo also designed a virtual currency called "Bit Gold," a decade before Bitcoin was introduced. Szabo was often rumored to be the real Satoshi Nakamoto, the anonymous Bitcoin inventor, which he denied. [1][6]
The launch of the Bitcoin blockchain in 2009 supported the first "protocol smart contract," which established a set of conditions that must be met to transfer BTC, such as the sender signing with the correct private key. By 2012, the Bitcoin network evolved to support multi-signature (multisig) transactions, a more advanced form of smart contract requiring multiple private keys to approve a transaction. [1]
The modern era of smart contracts began with the publication of the Ethereum whitepaper in 2013 by Vitalik Buterin, which proposed a new type of blockchain for more versatile, programmable smart contracts. Ethereum launched in 2015, functioning as a "world computer" capable of running many independent and complex smart contracts simultaneously, significantly expanding their capabilities. [1][3]
Smart contracts operate on a dedicated virtual machine embedded within a blockchain, following the logic: "if/when x event occurs, then execute y action." [1] By running on a decentralized network instead of a central server, they enable multiple parties to achieve a shared, tamper-proof result without needing to trust each other. A single smart contract can encompass various conditions, and an application may employ multiple smart contracts to facilitate an interconnected series of processes. [5]
Because they operate on top of blockchains, smart contracts are automatically and deterministically executed exactly as programmed. This guarantees that the contract's outcome cannot be changed by any single party. A variety of programming languages are used for development, with Solidity (for Ethereum and compatible chains), Vyper, and Rust being among the most prominent. [1][3]
A prominent example of this risk was the attack on The DAO in June 2016, which drained US$50 million in Ether. The incident was ultimately rectified via a controversial hard fork of the Ethereum blockchain to claw back the funds from the attacker. [4]
Blockchains are inherently isolated systems and cannot natively access external, off-chain data such as real-world asset prices, weather data, or sports results. This is known as the "oracle problem" and limits the scope of smart contracts without a supplementary solution. [1]
To overcome this limitation, smart contracts use "oracles," which are secure middleware services that connect blockchains to external systems. Oracles provide off-chain data and computational resources, enabling "hybrid smart contracts" that combine on-chain code with off-chain infrastructure. This connection allows smart contracts to react to real-world events, greatly expanding their potential use cases. [1][5]
Not all blockchains have the native ability to run complex, programmable smart contracts. The key differentiator is the underlying network's capacity to execute and store arbitrary application logic, often through a built-in virtual machine.
Notable platforms supporting advanced smart contracts include:
Collectively, these platforms facilitate the creation of highly customized logic for a wide range of decentralized applications. [1]
Decentralized finance (DeFi) encompasses applications leveraging smart contracts to replicate traditional financial products such as money markets, options, stablecoins, exchanges, and asset management. These applications employ permissionless composability to combine services, creating new financial primitives. Smart contracts within DeFi can securely manage user funds, holding them in escrow and distributing them between users based on predetermined conditions. For instance, BarnBridge automates trades for users seeking fixed asset exposure, and Aave facilitates permissionless and decentralized lending and borrowing through smart contracts. [1][3]
Token smart contracts are used to create, track, and assign ownership rights to specific digital tokens existing on blockchain networks. The token contract programs functionalities into the tokens it issues, providing holders features like utility/insurance in a dApp (utility token), voting weight in a protocol (governance token), equity in a company (security token), ownership claim to a unique real-world or digital asset (non-fungible token), and more. For example, the FIL token is used to pay for Filecoin’s decentralized storage services and the COMP token allows users to participate in the governance of Compound protocol. [1]
Blockchain-based games use smart contracts for tamper-proof execution of in-game actions. One example is PoolTogether, a no-loss savings game where users stake their funds in a shared pool that is then routed into a money market where it earns interest. After a predefined period, the game ends and a winner is randomly awarded all the accrued interest while everyone else can withdraw their original deposit. [1]
Similarly, limited-edition NFTs can have fair distribution models and RPGs can support unpredictable loot drops using randomness, helping to ensure all users have a fair shot at getting rare digital assets. Many projects access randomness using Chainlink Verifiable Random Function (VRF)—a random number generator (RNG) that uses cryptography to prove it's tamper-proof, meaning the RNG process is publicly auditable. [1]
Parametric insurance ties payouts directly to predefined events, leveraging smart contracts for tamper-proof creation and execution based on data inputs. For instance, crop insurance can be implemented through smart contracts, where policies are linked to specific weather conditions like seasonal rainfall. Upon policy completion, the smart contract automatically issues payouts if trusted oracle data confirms the predefined conditions were met. Platforms like Arbol use smart contracts and oracles for weather-based parametric insurance. This model ensures timely payouts with reduced overhead and opens the supply side of insurance to the public through smart contracts where users can deposit funds into a pool to earn premiums. [1][2]
Smart contracts can be utilized in voting and governance within a DAO (Decentralized Autonomous Organization) by encoding the rules and procedures for decision-making directly into the contract code. Participants in the DAO can then interact with the smart contract to cast votes, propose changes, or participate in governance decisions. This ensures transparency, immutability, and tamper-proof execution of the voting process, enhancing the democratic and decentralized nature of DAO governance. Smart contracts can automate the tallying of votes, enforce voting rules, and execute decisions based on predefined conditions, providing an efficient and trustless mechanism for managing the DAO's affairs. [5]
Smart contracts can be employed in blockchain crowdfunding by automating the fundraising process and ensuring transparent and secure handling of contributions. Through a predefined set of rules encoded in the smart contract, participants can send contributions to a crowdfunding campaign. The smart contract then automatically manages the release of funds based on specific conditions, such as reaching a funding goal or a predetermined timeline. This eliminates the need for an intermediary and enhances trust among participants, as the contract's execution is verifiable on the blockchain. Additionally, smart contracts can facilitate the distribution of tokens or rewards to contributors based on the terms set within the contract. [5]
The potential applications for smart contracts extend to numerous other sectors, including supply chain management for automating payments upon delivery, real estate transactions, stock and commodity trading, and healthcare for managing sensitive data with patient consent. [2]