Smart Contracts Introduction
A smart contract is a tamper-proof program that runs on a blockchain network when certain predefined conditions are satisfied.
What Is a Smart Contract?
Smart contracts are computer programs that are hosted and executed on a blockchain network. Each smart contract consists of code specifying predetermined conditions that, when met, trigger outcomes. By running on a decentralized blockchain instead of a centralized server, smart contracts allow multiple parties to come to a shared result in an accurate, timely, and tamper-proof manner.
Smart contracts are a powerful infrastructure for automation because they are not controlled by a central administrator and are not vulnerable to single points of attack by malicious entities. When applied to multi-party digital agreements, smart contract applications can reduce counterparty risk, increase efficiency, lower costs, and provide new levels of transparency into processes.
History of Smart Contracts
Smart contracts were first coined by American computer scientist Nick Szabo in 1994. In his seminal writing, he gave a broad smart contract definition as follows: “a computerized transaction protocol that executes the terms of a contract,” with general objectives to “satisfy common contractual conditions, minimize exceptions both malicious and accidental, and minimize the need for trusted intermediaries.”
While a general notion of smart contracts could be seen in systems like vending machines (e.g., a specific code leads to an expected snack), blockchains formed the foundation of smart contracts that were digital, tamper-proof, and permissionless. The introduction of the Bitcoin blockchain in 2009 supported arguably the first protocol smart contract—establishing a set of conditions that had to be satisfied to transfer Bitcoins between users on the network. These conditions include the user signing the transaction with the correct private key that matches their public address (akin to a password linked to a specific account) and the user owning enough funds to cover the transaction.
The Bitcoin blockchain then evolved to offer another major type of smart contract in 2012 called a multi-signature transaction. A multisig transaction requires a defined number of people (public keys) to sign a transaction with their private keys before it’s considered valid. This increases the security of user funds by mitigating single point of failures like a stolen or lost private key.
Blockchains began to experiment over the next few years by adding new programmatic conditions (called operation codes or opcodes). However, the next major leap in smart contracts came upon the publishing of the Ethereum whitepaper by Vitalik Buterin in 2013. In 2015, Ethereum launched as a new type of blockchain for programmable smart contracts. Instead of the blockchain acting effectively as a single smart contract application or offering a few limited opcodes, the Ethereum smart contract blockchain offered a “world computer” that could run many independent smart contracts at the same time.
How Smart Contracts Work
Smart contracts are tamper-proof programs on blockchains with the following logic: “if/when x event happens, then execute y action.” One smart contract can have multiple different conditions and one application can have multiple different smart contracts to support an interconnected set of processes. There are also multiple smart contract languages for programming, with Ethereum’s Solidity being the most popular.
Any developer can create a smart contract and deploy it on a public blockchain for their own purposes, e.g., a personal yield aggregator that automatically shifts their funds to the highest-earning application. However, many smart contracts involve multiple independent parties that may or may not know one another and don’t necessarily trust one another. The smart contract defines exactly how users can interact with it, involving who can interact with the smart contract, at what times, and what inputs result in what outputs. The result is multi-party digital agreements that evolve from today’s probabilistic state, where they will probably execute as desired, to a new deterministic state where they are guaranteed to execute according to their code.
Smart Contract Examples
One purpose of a smart contract is to automate a specific business process between a distinct group of entities. These entities collectively come to an agreement on all the smart contract’s terms like payouts, process flow, and dispute resolutions. A simple smart contract example for global trade may have terms like:
Term 1: If the goods arrive on time, then execute a payment from the retailer to the supplier in full amount.
Term 2: If the goods arrive one day late, then execute a payment from the retailer to the supplier for 98% of the full amount.
Other smart contracts support public decentralized applications (dApps) that anyone can interact with without needing any permissions. Public dApps are often open-source so anyone in the world can inspect exactly how they function before deciding whether or not to interact with them. One example of a public dApp is a decentralized lending/borrowing market, which may have the following terms:
Term 1: If the user deposits collateral into the specific smart contract, they can receive a loan that’s up to 50% of the value of their collateral (i.e., $100 deposit can borrow up to a $50 loan).
Term 2: If the user’s collateralization ratio (collateral/outstanding loan value) drops below 200%, then the user’s collateral is automatically liquidated and transferred to the lenders to ensure they don’t lose money.
Term 3: Lenders can deposit funds into a specific contract that other users can borrow from at predefined collateralization ratios, while the lender receives a claim to a portion of the interest rate payments.
Smart Contract Benefits
Most traditional digital agreements involve two parties that don’t know each other, introducing risk that either participant won’t uphold their commitments. To resolve counterparty risk, digital agreements are often hosted and executed by larger, centralized institutions like a bank that can enforce the contract’s terms. These digital contracts can be directly between a user and a large company or involve a large company acting as a trusted intermediary between two users. While this dynamic allows many contracts to exist that otherwise wouldn’t take on such risk, it also creates a situation where the larger, centralized institutions exert asymmetrical influence over the contracts.
Smart contracts improve upon digital agreements by offering several advantages.
Security – Running the contract on decentralized blockchain infrastructure ensures there is no central point of failure to attack, no centralized intermediary to bribe, and no mechanism for either party or a central admin to use to tamper with the outcome.
Reliability – Having the contract logic redundantly processed and verified by a decentralized network of nodes provides strong tamper-proof, uptime, and correctness guarantees that the contract will execute on time according to its terms.
Equitable – Using a decentralized network to host and enforce the terms of the agreement reduces the ability of a for-profit middleman to use their position of privilege to rent-seek and siphon off value.
Efficiency – Automating the backend processes of the agreement—escrow, maintenance, execution, and/or settlement—means neither party has to wait for manual data to be entered, the counterparty to fulfill their obligations, or a middleman to process the transaction.
Smart Contract Use Cases
Rights Management (Tokens)
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.
Financial Products (DeFi)
Decentralized finance (DeFi) consists of applications that use smart contracts to recreate traditional financial products and services such as money markets, options, stablecoins, exchanges, and asset management, as well as combine multiple services to create new financial primitives via permissionless composability. The smart contract can hold user’s funds in escrow and distribute them between users based on predefined conditions. For example, BarnBridge uses smart contracts to automate trades for users wanting fixed asset exposure to a price pair (e.g., 45% token A, 55% token B), and Aave uses smart contracts to facilitate lending and borrowing in a permissionless and decentralized manner.
Gaming and NFTs
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 time period, the game ends and a winner is randomly awarded all the accrued interest while everyone else can withdraw their original deposit. 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.
Parametric insurance is a type of insurance where a payout is tied directly to a specific predefined event. Smart contracts provide tamper-proof infrastructure for creating parametric insurance contracts that trigger based on data inputs. For example, crop insurance can be created using smart contracts, where a user purchases a policy based on specific weather information like seasonal rainfall in a geographic location. At the end of the policy, the smart contract will automatically issue a payout if the amount of rainfall in the specific location exceeds the original stated amount. Not only do end-users receive timely payouts with less overhead, but the supply side of insurance can become open to the public via smart contracts. The smart contract allows users to deposit funds into a pool and then distributes collected premiums to pool participants based on the percentage of their contribution to the pool.
Discover the wide range of smart contract applications that blockchain developers are building with Chainlink oracles, from DeFi protocols to NFTs, parametric insurance, and decentralized identity solutions.
Smart Contract Limitations
One of the inherent limitations of smart contracts is that the underlying blockchains they run on are isolated networks, meaning blockchains have no built-in connection to the outside world. Without external connectivity, smart contracts cannot communicate with external systems to confirm the occurrence of real-world events nor can they access cost-efficient computational resources. Similar to a computer without the Internet, smart contracts are extremely limited without real-world connectivity. For example, they can’t know the price of an asset before executing a trade, they can’t check the average monthly rainfall before paying out a crop insurance claim, and they cannot verify that goods have arrived before settling with a supplier.
Thus, the major evolution underway in the blockchain industry is programmable smart contracts that connect with real-world data and traditional systems outside a blockchain, expanding the inputs and outputs used within smart contract logic. These hybrid smart contracts use secure middleware known as an oracle to combine on-chain code with off-chain infrastructure—e.g., trigger a smart contract with external data or settle a contract off-chain on a traditional payment rail.
Similar to the Internet’s effect on computers, oracles are the key to connecting emerging blockchain networks with today’s legacy systems to enable interconnected, performant, and privacy-preserving smart contracts that retain the security and reliability of the underlying blockchain network. By enabling hybrid smart contracts, oracles greatly expand and enhance the valuable properties of blockchains, leading to superior digital agreements based on cryptographic truth across more industries and use cases.