Hybrid smart contracts combine code running on the blockchain (on-chain) with data and computation from outside the blockchain (off-chain) provided by Decentralized Oracle Networks. Hybrid smart contracts enable advanced forms of economic and social coordination that have the tamper-proof and immutable properties of blockchains yet leverage secure off-chain oracle services to attain new capabilities, such as scalability, confidentiality, order fairness, and connectivity to any real-world data source or system.

In the following article, we define the role that hybrid smart contracts play within emerging blockchain-based trust models and showcase the many decentralized services that Chainlink oracles provide to extend their capabilities. We then explain how this ultimately opens up a new generation of hybrid blockchain-based applications that have the required real-world properties needed to improve how society collaborates across nearly every major industry in the future.

How Oracles Extend Blockchain-Based Collaboration

At their core, blockchains are computing infrastructure designed to facilitate one key function: highly trustworthy collaboration. Trust is what gives participants a firm belief in the reliability, truth, ability, or strength of the collaboration. The most common way to establish trust in a collaborative process is a contract, which defines the legal and business obligations of each participant and the penalties/rewards of their actions. Unfortunately, the enforcement mechanism of contract obligations is far from perfect today, particularly when one participant has an asymmetrical advantage like unfair influence over the enforcement infrastructure, a more clear understanding of the fine print, or the time and capital to prolong the arbitration process. This has resulted in a contract system where belief in a counterparty’s brand becomes central to determining their trustworthiness.

Blockchains are a collaboration-enabling technology that replace brand-based trust with math-based trust by shifting the hosting, execution, enforcement, and custody mechanisms of a contract to software logic run across a decentralized network that no individual participant can undermine. Akin to a computer without Internet, blockchains are highly trustworthy because they are enclosed networks, purposely limited to facilitating a very small, predefined range of collaboration types that are easy to enforce, such as transferring tokens between addresses on a self-contained ledger. While this isolation and narrow spectrum of functionality generates the tamper-proof and deterministic guarantees that make blockchains valuable, it also prohibits support for any type of collaboration that requires data, computation, or features not native to the specific blockchain.

The desire to expand the types of collaboration possible on blockchains led to the birth of oracles and subsequently the introduction of hybrid smart contracts. Oracles provide blockchains with secure gateways to the outside world so that smart contract applications can verify external events, trigger actions on external systems, and leverage computations not possible or practical to do on-chain.

As outlined in the Chainlink 2.0 Whitepaper, the off-chain services offered by Decentralized Oracle Networks (DONs) greatly expand the types of on-chain collaborations that smart contracts can support. This is already clearly evident in the rapid rise of Decentralized Finance (DeFi), which accelerated once Chainlink’s decentralized oracle networks made external financial market data available on-chain, supporting hybrid smart contract protocols like Aave’s money markets, Synthetix’s derivatives platform, dYdX’s leveraged trading markets, Ampleforth’s algorithmic stablecoin, and much more.

The Composition of Hybrid Smart Contracts

A hybrid smart contract is an application that consists of two parts: 1) smart contract—code that runs exclusively on the blockchain, and 2) decentralized oracle network(s)—secure off-chain services that support the smart contract. The two components interact with one another seamlessly and securely to form a single hybrid smart contract application. The result is on-chain code that is augmented in a variety of unique and important ways, opening up many new use cases that would not be possible through on-chain code alone due to technical, legal, or financial constraints.

Hybrid smart contracts synchronize two distinctly different computing environments to create a superior application that neither a blockchain or an oracle network could achieve alone, particularly because each environment specializes in providing features that the other does not. On-chain code runs in an extremely secure and limited-functionality blockchain environment with a reduced attack surface area, providing users a high-degree of execution and storage determinism—the code will run exactly as written and results will remain permanently and immutably stored. Conversely, DONs run off-chain and thus offer infinitely more functionality flexibility and data accessibility.

It’s important to note that DONs still provide a very high level of tamper-resistant and reliability to match the guarantees provided by the smart contract, but they do so in an isolated off-chain environment using a multitude of varying security approaches. Each DON provides a customized decentralized service to a specific application, meaning other smart contracts on the same blockchain are not tied to that DON’s performance nor is the underlying blockchain consensus mechanism that secures all smart contracts at risk. As standalone services, DONs are not only advantageous from a security perspective, but they also enable the flexibility needed to verify and compute upon an infinitely more complex and open-ended off-chain world.

For example, one smart contract may only incorporate a DON for its particular external data needs if it's highly decentralized and backed by a substantial amount of crypto-economic security, while a different smart contract may prefer a DON with a more specific set of highly reputable nodes that use advanced cryptographic techniques to perform private verifiable computation. Upon such heterogeneous network architecture, thousands to millions of DONs can run in parallel without cross-dependencies to provide purpose-built decentralized services to specific applications, although some users may share the costs of the same DON service (e.g., numerous DeFi protocols currently use and fund the Chainlink ETH/USD Price Feed Oracle). This framework is important to servicing the needs of all blockchains and applications simultaneously, such as applications running on a high-speed blockchain wanting external data and privacy, while applications on a highly decentralized blockchain also needing scalable computation.

How Hybrid Smart Contracts Combine On-Chain and Off-Chain Computation

To further understand the difference between the on-chain and off-chain components, let’s identify the distinct roles of each:

On-Chain: Blockchain

  • Maintain a persistent ledger that provides authoritative custody of users’ assets and interacts with private keys
  • Execute final settlement by processing irreversible transactions that transfer value between users
  • Provide dispute resolution and guardrails to secure the proper functioning of the off-chain services performed by a DON

Off-Chain: Decentralized Oracle Network

  • Fetch, validate, secure, and deliver data from external APIs to smart contracts running on blockchains and Layer-2 solutions
  • Perform various types of computations for smart contracts running on blockchains and Layer-2 solutions
  • Relay outputs of smart contract code to other blockchains or external systems
Hybrid smart contracts
Hybrid smart contracts combine on-chain code with off-chain decentralized oracle networks to enable more advanced blockchain-based applications.

With hybrid smart contracts defined, let’s explore the many decentralized services available through Chainlink DONs that can greatly enhance a smart contract. The decentralized services will be split up into two broad categories: off-chain data and off-chain computation.

Off-Chain Data

DONs can be used to bridge various types of external data to and from blockchains, enabling hybrid smart contracts to be written around those specific pieces of data. Some of the initial data types made accessible include:

  • Price Feeds — asset price data that’s been aggregated from hundreds of exchanges, weighted by volume, and cleaned of outliers and wash trading.
  • Proof of Reserve — up-to-date data about the current reserve balances backing tokenized assets, such as the BTC reserves collateralizing WBTC or the USD bank account collateralizing TUSD.
  • Any API — premium data from password-protected APIs, ranging anywhere from weather forecasts and sports match results to information from an enterprise backend and IoT network.
  • Blockchain Middleware — abstraction layer for an off-chain system to read and write data to and from smart contracts on any blockchain network.

Off-Chain Computation

DONs can perform a variety of off-chain computations on behalf of the smart contract to help it achieve specific inputs or generate certain features not possible on its specific blockchain, such as privacy, scalability, and order fairness. Some of the current and upcoming off-chain computations possible through DONs include:

  • Keeper Network automation bots that perform regular maintenance tasks for the smart contract, waking it up when it needs to perform key on-chain functions.
  • Off Chain Reporting (OCR) — scalable aggregation of oracle node responses in a DON that are then delivered on-chain in a single transaction to reduce on-chain costs.
  • Scalable Computation — high-throughput, low-cost contract execution for standalone smart contracts, which syncs on-chain periodically using existing layer-2 technology.
  • Verifiable Randomness Function (VRF) — secure and verifiable random number generation backed by cryptographic proofs that prove process integrity.
  • Data and Computation Privacy — privacy-preserving oracle computation that makes sensitive data confidentially available to smart contracts using zero-knowledge proofs (DECO), trusted hardware (Town Crier), secure multi-party computation, and/or using select DON committees.
  • Fair Sequencing Services (FSS) — decentralized transaction ordering based on a predefined notion of fairness, preventing frontrunning and miner extractable value (MEV).
  • On-Chain Contract Privacy — transaction privacy for a smart contract via a decorrelation between the contract logic and settlement output, using the DON to relay communication between the two parts such as with Mixicles.
Chainlink Decentralized Services
Chainlink Decentralized Oracle Networks provide a wide range of services that extend the capabilities of hybrid smart contract applications.

What Hybrid Smart Contracts Mean for Global Industries

DONs enable an advanced hybrid smart contract framework that brings about seamless, secure, and universal automation between any and all independent entities operating across disparate systems and blockchains. Chainlink helps developers overcome the current technical limitations of smart contracts by empowering them to leverage the deterministic execution guarantees of blockchain technology while also securely outsourcing key functions like external connectivity, privacy, scalability, and order-fairness to DONs. Not only do hybrid smart contracts open up more trusted and efficient collaboration between different network participants, but they offer a way to connect existing infrastructure to blockchain networks with zero backend modifications.

DONs unlock a large number of smart contract applications that require either privacy or scalability, including most enterprise use cases and many gaming and financial applications that need high-throughput and real-time decision making. Hybrid smart contracts also give rise to new use cases that have never been seen before, such as those using verifiable randomness and decentralized transaction ordering to set a new precedent for math-based economic fairness and transparency within social systems.

Some of the major industries already or soon to be impacted by hybrid smart contracts include:

  • Identity — identity information that can be verified in an automated and privacy-preserving manner. Smart contracts can define the personal information required and the actions taken upon receiving it, while DONs can perform computations that verify a user’s personal information without exposing it publicly, revealing it to the counterparty, and/or storing it in an external system.
  • Finance — open financial markets that are censorship resistant, globally accessible, and transparent. Smart contracts can define the rules of engagement for both the buyers and sellers, while DONs can price products and settle markets using external data, as well as perform computations for optional features like transaction concealment, KYC verification, fair transaction ordering, and high-speed off-chain processing.
  • Supply Chain — multi-party trade agreements that operate on a shared ledger, digitize product lines, and/or automate actions across disparate systems using verified data. Smart contracts can outline the various obligations, payment terms, and penalties, while DONs can help track shipments, monitor quality control, verify customer identities, and trigger settlement payments using a combination of privacy-preserving computations and external data feeds from IoT networks, web servers, other blockchains, and enterprise backends.
  • Insurance — parametric insurance that’s facilitated by two-sided prediction markets based on pre-specified events. Smart contracts can define the premiums and claims processes, while DONs can connect the contract to external data feeds for quoting and arbitrating claims. DONs can also perform risk assessment calculations, fetch complex risk assessment outputs (e.g., from a cloud platform), and confidentially verify IDs.
  • Gaminggaming platforms that automate the issuance of rewards, give users complete ownership of in-game assets via NFTs , and provide definitive proof that all players have an equal opportunity of winning. Smart contracts can define gameplay and rewards distribution models, while DONs can provide tamper-proof randomness to ensure provably unbiased gameplay and fair prize distributions. With DONs, gaming dApps can also connect real-world data feeds like IoT sensor readings for augmented reality and process certain game functions off-chain to achieve higher performance.
  • Marketing — marketing campaigns that distribute rewards automatically in real-time based on data-driven performance objectives. Smart contracts can define a tiered payout model with specific milestones, while DONs can validate that performance metrics were hit and provide confidential computations on customer data and wider market trends for advanced campaign assessments.
  • Governance — distributed communities that securely and fairly manage shared systems and pooled assets. Smart contracts can define the entire governance framework, while DONs can provide external data and computations to trigger profit sharing, deduct shared fees, check identities to mitigate Sybil attacks, verify membership commitments, or even automate decision-making.

Ultimately, DONs can provide all the services that blockchains don’t inherently support, as well as bootstrap off-chain services by extending cryptographic security guarantees to existing data and systems. A hybrid smart contract architecture helps realize a broader vision of collaboration based on decentralized systems, allowing blockchains and non-blockchain infrastructure to seamlessly interact in a secure, reliable, scalable, confidential, customizable, and/or universally connected manner. Even with cryptocurrency being a multi-trillion dollar asset class and DeFi nearing a $100B economy, the far-reaching applicability of hybrid smart contracts and Chainlink Decentralized Oracle Networks is a clear sign that the blockchain ecosystem has only scratched the surface of what’s to come.

If you want to start building hybrid smart contract applications today and need some type of external data or computation, refer to our documentation, ask a technical question in Discord, or set up a call with one of our experts.

To learn more, visit chain.link, subscribe to the Chainlink newsletter, and follow Chainlink on Twitter, YouTube, and Reddit.