What is a hybrid smart contract?

Dmytro Nasyrov
Pharos Production
Published in
10 min readSep 18, 2024

Hybrid smart contracts combine code running on-chain with off-chain data and computation provided by decentralized oracle networks. Hybrid smart contracts enable advanced forms of economic and social cooperation that leverage blockchain's tamper-resistant and immutable properties but leverage secure off-chain oracle services to achieve new capabilities such as scalability, privacy, order fairness of transactions, and connectivity to any real-world external data source or system. In this article, we define hybrid smart contracts' role in evolving blockchain-based trust models and showcase the many decentralized services that Oracle provides to enhance their capabilities. We then explain how this ultimately enables a new generation of hybrid blockchain-based applications with all the properties needed to improve the way society collaborates in virtually every major industry in the future.

Blockchain Oracles

A blockchain is a computing infrastructure that facilitates one key function: highly reliable cooperation. Trust gives participants a firm belief in the cooperation's reliability, truth, validity, possibility, or strength. The most common way to establish trust in a collaborative process is through a contract, which defines each participant's legal and business obligations and the penalties/rewards for their actions. Unfortunately, the mechanism for enforcing contractual obligations today is imperfect, especially when one participant has an asymmetric advantage, such as unfair influence over the enforcement infrastructure, a clearer understanding of the fine print, or the time and capital to drag out arbitration. This has led to a contractual system in which faith in the counterparty’s brand becomes a central factor in determining its trustworthiness.

Blockchain is a collaborative technology that replaces brand-based trust with mathematical trust by moving the mechanisms of contract placement, execution, enforcement, and storage to software logic running on a decentralized network that any participant cannot hack. Like a computer without the Internet, a blockchain is highly trusted because it is a closed network, intentionally limited to supporting a very small, pre-defined range of transaction types that are easy to enforce, such as transferring tokens between addresses on the ledger. While this isolation and narrow range of functionality create the tamper-proof and deterministic guarantees that make blockchain valuable, it also prohibits support for any transaction that requires data, computation, or functionality not native to the specific blockchain.

The desire to expand the types of operations possible on the blockchain led to the emergence of oracles and, later, 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 perform computations that are impossible or impractical on the blockchain.

Off-chain services offered by decentralized oracle networks (DON) significantly expand the types of on-chain operations that smart contracts can support. This is already well demonstrated by the rapid growth of decentralized finance (DeFi), which has accelerated as decentralized oracle networks have made external financial market data available on the blockchain, supporting hybrid smart contract protocols such as Aave financial services, Synthetix derivatives platform, dYdX leveraged trading markets, Ampleforth algorithmic stablecoin, and more.

Hybrid smart contracts

A hybrid smart contract is an application that consists of two parts:

  1. A smart contract is a code that runs exclusively on the blockchain.
  2. A decentralized oracle network(s) is a secure off-chain service that supports the smart contract.

These two components interact seamlessly and securely to form a hybrid smart contract application. As a result, the on-blockchain code is enhanced in various unique and important ways, opening up a host of new use cases that would not be possible with on-blockchain code alone due to technical, legal, or financial constraints.

Hybrid smart contracts synchronize two different computing environments to create a unique application that neither a blockchain nor an oracle network could achieve alone, especially since each environment specializes in providing functionality that the other does not. On-blockchain code runs in an extremely secure, limited-function blockchain environment with reduced attack surface areas, providing users with a high degree of execution and storage determinism — the code will execute exactly as written, and the results will be stored permanently and immutably. Conversely, DONs operate off-blockchain and thus offer infinitely greater flexibility, functionality, and data availability.

Importantly, DONs still provide a very high level of tamper resistance and reliability consistent with the guarantees provided by a smart contract. Still, they do so in an isolated off-chain environment using various security approaches. Each DON provides a customized, decentralized service for a specific application, meaning that other smart contracts on the same blockchain are not tied to the performance of that DON or compromise the underlying consensus mechanism that secures all smart contracts. As standalone services, DONs provide the security benefits and the flexibility needed to verify and compute in the infinitely more complex and open world of off-chain networks. For example, one smart contract may only use a DON for its specific off-chain data needs if it is highly decentralized and backed by a significant crypto-economic guarantee.

In contrast, another smart contract may prefer a DON with a more specific set of highly reputable nodes that use advanced cryptographic techniques to perform private, verifiable computations. In such a heterogeneous network architecture, thousands or millions of DONs can operate in parallel without cross-dependencies to provide custom decentralized services to specific applications. However, some users may share the cost of the same DON service (e.g., numerous DeFi protocols currently use and sponsor ETH/USD price feed oracles). This structure is important to simultaneously serve the needs of all blockchains and applications, such as applications running on a high-speed blockchain requiring external data and privacy. At the same time, applications on a highly decentralized blockchain also require scalable computing.

On-Blockchain and Off-Blockchain Computing

To better understand the difference between the on-chain and off-chain components, let us define the different roles of each:

On-chain: Blockchain

  • Maintaining a permanent ledger that provides authoritative storage of user assets and interacts with private keys
  • Performing final settlement by processing irreversible transactions between users
  • Resolving disputes and safeguards to ensure the proper functioning of off-chain services provided by DON

Off-chain: Decentralized Oracle Network

  • Receive, validate, secure, and deliver data from external APIs to smart contracts running on the blockchain and L2 solutions.
  • Perform various computations for smart contracts running on the blockchain and L2 solutions.

Decentralized Oracle Services

Now that we have defined hybrid smart contracts, let us explore the decentralized services available through DONs that can greatly enhance the smart contract. The decentralized services will be divided into off-chain data and off-chain computation.

Off-chain data

Decentralized oracle networks can feed various types of external data into and out of the blockchain, allowing hybrid smart contracts to be built on top of those specific pieces of data. Some of the initial types of data available for use include:

Price Feeds — asset price data collected from hundreds of exchanges, volume-weighted and cleaned of outliers and wash trades

Proof of Reserve — up-to-date data on the current reserve balances backing tokenized assets, such as BTC reserves backing WBTC or a USD bank account backing TUSD

Any API — premium data from secure APIs, ranging from weather forecasts and sports scores to enterprise backend and IoT network information

Blockchain Middleware — an abstraction layer for an external off-chain system to read and write data to and from smart contracts on any blockchain network

Off-Blockchain Computing

DONs can perform various off-chain computations on behalf of a smart contract to help it achieve certain inputs or create certain features unavailable on a specific blockchain, such as privacy, scalability, and transaction order fairness. Some of the existing and planned off-chain computations that can be performed using DONs include:

Keeper Network — automated bots that perform regular maintenance tasks on a smart contract, waking it up when it needs to perform key functions on the blockchain

Off-Chain Reporting (OCR) — scalable aggregation of Oracle node responses on DON, which is then delivered to the blockchain in a single transaction to reduce the cost of executing an operation on the blockchain

Scalable Computation — high-performance, low-cost contract code execution for offline smart contracts that is periodically synchronized on the blockchain using L2 technology

Verifiable Randomness Function (VRF) — secure and verifiable random number generation backed by cryptographic proofs that verify the integrity of the process

Data and Computation Privacy — privacy-preserving oracle computation that makes sensitive data available to smart contracts using zero-knowledge proofs (DECO), trusted hardware (Town Crier), secure multi-party computation, and/or using selected groups of DON nodes.

Fair Sequencing Services (FSS) — decentralized ordering of transactions based on a predefined notion of fairness, preventing preemption and miner extractable value (MEV)

On-Chain Contract Privacy — transaction privacy for a smart contract through decorrelation between the contract logic and the calculation result, using DON to relay the communication between these two parts.

Cross-Chain Interoperability Protocol (CCIP)— a cross-chain interoperability protocol that allows working with smart contracts on different blockchains

Hybrid Smart Contracts and Global Industries

DONs enable an advanced hybrid smart contract framework that enables seamless, secure, and universal automation between independent entities operating across disparate systems and blockchains. Oracles help developers overcome the current technical limitations of smart contracts by allowing them to leverage the deterministic execution guarantees of blockchain technology while reliably outsourcing key features such as external data sources, privacy, scalability, and transaction order fairness to DONs. Hybrid smart contracts enable more reliable and efficient collaboration between network participants and offer a way to connect existing infrastructure to blockchain networks with minimal backend changes.

DONs enable a wide range of smart contract applications that require privacy or scalability, including most enterprise applications and many gaming and financial applications that require high throughput and real-time decision-making. Hybrid smart contracts also give rise to new, previously unseen use cases, such as using verifiable randomness and decentralized transaction ordering to create a new precedent for mathematical economic fairness and transparency in social systems.

Some of the major industries that are already affected or will soon be affected by hybrid smart contracts include:

Identity — Personal information that can be verified automatically and in a privacy-preserving manner. Smart contracts can define the personal information required and the actions taken upon receipt. DONs can perform computations that verify a user’s personal information without disclosing it publicly, disclosing it to a 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 rules of engagement for buyers and sellers, and DONs can set prices for goods, settle markets using external data, and perform computations for additional functions such as transaction obfuscation, KYC verification, fair transaction ordering, and high-speed off-chain processing.

Supply Chains — Multi-party trade contracts that operate on a shared ledger, digitize product lines, and/or automate actions across disparate systems using verified data. Smart contracts can define various obligations, payment terms, and penalties. At the same time, DONs can help track shipments, control quality, verify customer identity, and initiate settlement payments using a combination of privacy-preserving computation and external data from IoT networks, web servers, other blockchains, and enterprise backends.

Insurance — Parametric insurance facilitated by two-sided prediction markets based on pre-defined events. Smart contracts can define premiums and claim processes, and DONs can connect the contract to external data sources for quoting and arbitration of claims. DONs can also perform risk assessment calculations, retrieve complex risk assessment results (e.g., from a cloud platform), and privately verify identities.

Games — Gaming platforms that automate reward distribution, grant users full ownership of in-game assets via NFTs, and provide final proof that all players have an equal chance of winning. Smart contracts can define gameplay and reward distribution models, and DONs can provide tamper-proof randomness to prove the impartiality of gameplay and fair distribution of prizes. With DONs, gaming dApps (decentralized applications) can also incorporate real-world data, such as IoT sensor readings for augmented reality, and process certain game features off-chain to achieve higher performance

Marketing — Marketing campaigns that automatically distribute rewards in real time based on performance data. Smart contracts can define a tiered payout model with specific milestones. DONs can verify that performance metrics have been met and provide private computations on customer data and broader market trends for advanced campaign evaluation.

Governance — Distributed communities that securely and fairly manage shared systems and pooled assets. Smart contracts can define the entire governance structure. DONs can provide external data and computations for revenue distribution, deduction of shared payments, identity verification to mitigate Sybil attacks, membership commitment verification, or even automated decision-making.

Ultimately, decentralized oracle networks (DONs) can provide all the services that blockchain does not natively support and create off-chain services by extending cryptographic security guarantees to existing data and systems. Hybrid smart contract architecture helps realize the broader vision of decentralized collaboration by allowing blockchain and off-chain infrastructure to seamlessly interact in a secure, reliable, scalable, private, customizable, and/or universal manner. Despite cryptocurrency being a multi-trillion dollar asset class and the DeFi economy approaching $100 billion, the far-reaching applicability of hybrid smart contracts and decentralized oracle networks is a clear sign that the blockchain ecosystem is just beginning to explore what may lie ahead.

Feel free to drop a “Hi” at Pharos Production, where we bring software to life! 👋✨

https://pharosproduction.com

“Join our exciting journey with Ludo — the reputation system of the Web3 world! 🌍✨”

https://ludo.com

--

--

Dmytro Nasyrov
Pharos Production

We build high-load software. Pharos Production founder and CTO.