In the previous education article on blockchain, we identified a blockchain as a highly secure and reliable network for processing value exchange and storing data in an immutable ledger. While blockchains spawned new monetary instruments like Bitcoin, they have broader applications in powering conditional digital agreements known as smart contracts. In this article, we examine:

  • What a smart contract is
  • Why it provides value
  • How smart contracts have evolved
  • How they're being applied in the world today.

What is a Smart Contract

Digital agreements are electronically signed contracts that run on the Internet. For example, by clicking “Accept” to Uber’s terms and conditions, the rider agrees to pay the driver upon being delivered to their destination.

Most digital agreements involve two parties that don't know each other, introducing risk that either participant won't uphold their commitments. To resolve this counterparty risk, digital agreements are often hosted and executed by larger for-profit companies that can reliably 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 for-profit companies exert enormous control over the contracts.

A smart contract is a digital agreement that exists as an immutable software program on the blockchain with conditions attached to its execution. The simplest mental model for understanding conditional logic is “if x event happens, then execute y action.” For example, if Team A wins the sporting event then make a payout to Bob; if Team B wins then make a payout to Steve. Instead of manually entering the results of the sporting event, the smart contract is triggered directly by a piece of data informing it on the outcome. Upon receiving the data, the smart contract automatically executes an action often in the form of a payment.

Smart contracts are focused on moving business logic (contracts) from a probabilistic state where it will probably execute according to its terms, to a deterministic state where it is guaranteed to execute according to its terms. The reason smart contracts can boast such strong deterministic guarantees is that they run in a decentralized, permissionless, tamperproof, and always online blockchain environment. This creates a framework where contractual agreements are hosted by a neutral, decentralized network and technologically enforced by the occurrence of events.

The Value of a Smart Contract

Smart contracts offer several advantages over current digital agreements.

  • Security - Running the contract on decentralized 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 tamper with the outcome.
  • Reliability - Having the contract logic redundantly processed and verified by multiple independent nodes gives users strong manipulation resistance and network uptime guarantees that the contract will always execute on time according to its terms.
  • Equitable - Using a peer-to-peer based decentralized network to host and enforce the terms of the agreement reduces the amount of value being siphoned off by centralized for-profit intermediaries.
  • Efficiency - Automating the backend processes of the agreement—escrow, maintenance, execution, and 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.

The History of Smart Contracts

The most basic type of smart contract is a multi-signature smart contract. A multisig transaction states that a defined number of people (public keys) must sign a transaction with their private keys before it’s considered valid. Bitcoin was the first blockchain to introduce multisig transactions in 2012.

A simple framework for a multisig transaction on the Bitcoin blockchain
A simple framework for a multisig transaction on the Bitcoin blockchain

The next iteration saw the creation of protocol smart contracts—blockchains with a few core programmatic instructions (called opcodes) built-in. Protocol smart contracts are blockchains that operate as a single application with the ability to execute a few opcodes. However, protocol smart contracts are difficult to scale because each change to the smart contract (protocol) requires a hard fork—a radical change that mandates the creation of a new blockchain and for each node to upgrade their software.

Ethereum revolutionized smart contracts in 2015 by launching scriptable smart contracts, turning the blockchain into a “world computer” that runs many different applications at the same time. Developers manage their own set of smart contracts and can change them at any time without the need for a hard fork. The scripting language abstracts low-level development complexity, enabling developers to build smart contracts in a matter of days and weeks as opposed to months and years.

The current evolution is scriptable smart contracts that connect with real-world data and systems existing outside the blockchain (off-chain). Connected smart contracts use secure middleware known as an oracle to trigger the smart contract’s execution using off-chain data. Oracles can also allow the smart contract to send data to other systems, such as settling the smart contract off-chain by sending payment instructions to a traditional fiat payment system.

Chainlink oracles connect blockchains to data and traditional payment systems
Chainlink oracles can feed data (left) into blockchain-based smart contracts (center), as well as send payment instructions to off-chain payment networks (right)

How Are Smart Contracts Used Today

While we’re still in the early stages of development, we’ve identified four markets where smart contracts are beginning to take root thanks to their unique security and reliability guarantees.

Rights Management (Tokens)

Token contracts are used to create, track, and assign ownership rights to tokens. The token contract programs specific functionalities into the tokens it issues, providing holders utility/bandwidth in a dApp (utility token), voting weight in a protocol (governance token), equity in a company (security token), ownership claim to a real-world or digital asset (non-fungible token), and more. For example, the SIA token is used to pay for Siacoin’s decentralized cloud storage services, while 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, derivatives, stablecoins, exchanges, asset management, and more. The smart contract can hold user’s funds in escrow and distribute them to users as a result of market events. For example, Set Protocol automates portfolio management using market data, and Opium Exchange settles options contracts based on the price of assets at execution.

Gaming

Blockchain games use smart contracts for fraud-proof execution of in-game actions. One example is PoolTogether, a no loss savings game where users pool their savings in a lottery smart contract that is connected to a money market. The money market accumulates interest on the deposits, which are distributed to a winner based on random number generation (RNG). After the winner is chosen, everyone can withdraw their initial deposit. Similarly, smart contracts can generate rare in-game items like a one-time magical sword via RNG. Using Chainlink's Verifiable Random Function (VRF) as a source of RNG, users can trust and independently verify that the outcome was truly random and not manipulated by the developers of the game or the data source provider.

Insurance

Parametric insurance is a type of insurance where a payout is tied directly to a specific predefined event. Smart contracts provide tamperproof infrastructure for creating parametric insurance contracts that trigger as a result of data inputs. For example, Etherisc is building a flight insurance smart contract that automatically pays out when it receives flight status data. Not only do end-users receive more reliability guarantees on the contract, but retail investors can participate in the supply side of insurance through smart contracts that pool user deposits. The smart contract distributes profits based on the user’s contribution percentage into the pool.

Further Reading

Learn more by checking out the next article in the Education series about Data and APIs. Follow us on Twitter to get notified of upcoming article releases and join our Telegram for the latest news on Chainlink.