Oracle computation is a type of off-chain computation that uses decentralized oracle networks (DONs) to perform any computation while remaining anchored to blockchains to create trust-minimization guarantees.
- The purpose of oracles extends beyond delivering external data to blockchains. Oracles can also perform a new type of trust-minimized off-chain computation on behalf of smart contracts, referred to as “oracle computation.”
- Oracle computation falls in between centralized Web 2.0 computation and decentralized blockchain computation, achieving more performance and feature richness than blockchains while being more tamper-resistant and transparent than Web 2.0 systems.
- Oracle computation extends the capabilities of smart contract execution by increasing scalability, cost-efficiency, and privacy, as well as granting access to new features like order fairness, verifiable randomness, off-chain aggregation, and transaction automation.
- Chainlink offers applications a vast array of services powered by oracle computation, including Chainlink Automation, Chainlink Verifiable Random Function (VRF), Off-Chain Reporting (OCR), and the Cross-Chain Interoperability Protocol (CCIP).
Blockchain oracles are commonly recognized for their data transfer capabilities, i.e., fetching information from the real world and delivering it onto a blockchain so it can be referenced by a smart contract application. As described in the original Chainlink 1.0 whitepaper, decentralized oracle networks (DONs) are crucial to overcoming the “oracle problem” — the inability for blockchains to natively connect to external data resources — in a manner that’s highly reliable and tamper-proof.
The data delivery capabilities of DONs have enabled the creation of hundreds of different Chainlink Price Feeds, which provide smart contracts with access to financial market data. Chainlink Price Feeds are a major catalyst to the rapid growth of Decentralized Finance (DeFi) as a $100B+ dollar market. Some of DeFi’s leading applications rely on Chainlink Price Feeds to perform on-chain functions, including Aave, Compound, Synthetix, Liquity, and Sushi.
Beyond providing DeFi applications with market data, Chainlink oracles support many other smart contract use cases, such as supplying weather data to automate parametric insurance claims, sports data to settle prediction markets, and Proof of Reserve data to audit the reserves backing tokenized assets (e.g., verifying that stablecoins are backed 1-to-1 by US dollars). However, Chainlink DONs are not limited to transferring data, but can also perform off-chain computation tasks for smart contracts in a uniquely trust-minimized manner.
In the following article, we define oracle computation, provide real-world examples of Chainlink oracle computation, and showcase how hybrid smart contracts are leveraging both data and computation from Chainlink oracles to equip themselves with far more advanced capabilities than they could achieve with blockchain or traditional Web 2.0 computation alone.
Defining Oracle Computation and Its Unique Attributes
Computation is any type of calculation that’s defined logically by a set of instructions, such as an equation or algorithm. Computation will generate a deterministic output based on its input, i.e., if x condition is met, then output y is produced. An example of a very basic computation is taking a median (instructions) of five numbers (inputs) to get a result (output). While computation can be performed manually, most computation today is digital—written as code executed by a computer. Digital computation exists at all scales, from the digital watch on your wrist to large supercomputers training advanced machine learning algorithms.
A blockchain is a new type of decentralized computing that manages a distributed ledger containing digital assets and data. Blockchains can also store and process updates regarding the current “state” of smart contract applications. State can be thought of as an application’s own internal ledger within the wider blockchain ledger, with its own rules (instructions) as to how assets can move between accounts. Each state change by a smart contract requires the blockchain to perform some type of computation, such as:
- Verifying that signatures generated by a private key (i.e. password) match the corresponding public key (i.e. address) which originated the transaction
- Confirming public key addresses have sufficient account balances to cover the amount sent and network fees
- Executing the smart contract with the user’s inputs, and then using the generated output to update the contract’s state
- Generating Proof of Work hashes or Proof of Stake attestations during block production to extend the ledger with a new block containing the user’s transaction
- Checking blocks produced by other nodes within the network by re-executing all transactions stored within the block
While blockchains perform tamper-resistant computations for smart contracts, each has its own limitations. For example, highly decentralized blockchains offer computation that is optimized for censorship resistance, but comes with the trade-off of higher transaction costs and reduced speeds. Higher-speed blockchains optimize for higher-throughput transactions, but cannot natively support more advanced computations like end-to-end privacy or transaction automation.
Instead of blockchains performing all dApp computations, many computations can be performed off-chain with the results relayed on-chain. However, traditional off-chain computation from centralized Web 2.0 systems is not compatible with the guarantees that users expect from blockchain-based smart contracts. Without the entire smart contract being powered by computation that’s tamper-proof, transparent, and decentralized, there’s little point in using a blockchain in the first place. Thus, if smart contracts are going to route key computations off-chain to extend their capabilities, those off-chain networks must provide similar levels of security, reliability, and transparency as blockchains. Enter trust-minimized off-chain computation, otherwise known as oracle computation.
Oracle computation uses decentralized oracle networks (DONs) to perform off-chain computation on behalf of smart contracts while remaining anchored to blockchains to create trust-minimization guarantees. In this manner, DONs can perform any computation in a highly scalable, privacy-preserving, and feature-rich manner that’s on par with centralized Web 2.0 systems while also leveraging various blockchain techniques and dependencies to hold the oracle’s computation to higher standards of correctness, tamper-proofness, uptime, and transparency.
Through a synergistic relationship with blockchains, DONs create trust minimization — the confidence that a computation will execute exactly as expected. Oracle computation generates trust minimization using a similar decentralized architecture as blockchains to avoid single points of failure, while also being bound to user-defined service agreements that are enforced on-chain. Furthermore, a DON can be made to prove the correctness and integrity of its off-chain computation to a blockchain through verification techniques like multi-party computation, cryptographic proofs, fraud proofs, on-chain re-execution, and more. These verification techniques open up opportunities for further incentives for transparency and accountability, such as the triggering of various cryptoeconomic penalties or rewards as outlined in the smart contract.
Outside of trust minimization, the other major benefit of oracle computation is its extreme flexibility relative to blockchain computation. While blockchain computation is very standardized, oracle computation can encompass any design pattern, including varying levels of decentralization, specific node selection, customized schedules, predefined levels of crypto-economic security, combined security techniques, and more. In this manner, users can optimize their oracle computation to strike the right balance between security and performance based on their own needs, trust assumptions, and budget.
To better understand oracle computation, let’s look at how it is already being implemented throughout Chainlink to support more advanced hybrid smart contracts.
Examples of Oracle Computation in the Chainlink Network
As described in the Chainlink 2.0 Whitepaper, the long-term vision for the evolution of the Chainlink Network involves enhancing new and existing blockchain applications through DONs that provide both external data and trust-minimized off-chain computation. The Chainlink Network is already well on its way towards making this vision a reality through the array of services powered by Chainlink oracle computation, including Automation, Verifiable Randomness, Off-Chain Reporting, External Adapters, and the Cross-Chain Interoperability Protocol.
Chainlink Automation is a transaction automation solution that triggers blockchain computation to run when predefined conditions occur. Chainlink Automation uses oracle computation to monitor the state of on-chain or off-chain conditions, such as the passage of time (e.g. did 24 hours pass?) or the occurrence of events (e.g. did an asset hit a certain price?). Once a condition is met, Chainlink Automation submits a transaction on-chain that wakes up the smart contract and triggers it to run a predefined piece of code. Some common use cases of Chainlink Automation include triggering the liquidation of loans in lending protocols, executing limit orders in decentralized exchanges, and settling outcomes in prediction markets.
Chainlink Automation achieves trust minimization by using a decentralized network of nodes to perform off-chain computation of a contract’s logic that is then fully verified on-chain. Chainlink Automation nodes also cryptographically sign their responses on-chain so users can track their reliability, use an automated failover process to cover if one node fails to respond, and generate calldata to determine what part of the smart contract’s logic needs to be executed as a means of minimizing gas costs. Additionally, Chainlink Automation reduces the friction of creating automated dApps by removing the need for DevOps teams to perform these tasks manually or through centralized servers.
Chainlink Verifiable Randomness
Chainlink Verifiable Random Function (VRF) is a secure and verifiable random number generator (RNG) solution purpose-built for smart contract applications. Chainlink VRF works by computing a random value and a corresponding cryptographic proof off-chain, which is then verified on-chain before being sent to a user’s contract. The randomness produced cannot be manipulated without invalidating the cryptographic proof, helping prevent manipulation by users, oracles, or smart contract development teams. As a result, smart contracts can fully verify the integrity of randomness before using it in their application.
Some common dApp use cases for Chainlink VRF include: fairly assigning traits of varying rarity to NFTs during the minting process; introducing unbiased entropy into in-game mechanics like matchmaking players and opening loot boxes; and randomly selecting winners in lucky draws and no-loss prize games.
Chainlink Off-Chain Reporting and External Adapters
Chainlink Off-Chain Reporting (OCR) is an oracle network protocol that improves the efficiency of how data is computed off-chain by a Chainlink decentralized oracle network. OCR allows Chainlink nodes to aggregate their data into a single report off-chain using a peer-to-peer network, which is then submitted on-chain in a single transaction using a rotating node selection process with automated failover. By leveraging oracle computation, OCR lowers the on-chain gas costs per oracle update by up to 90% compared to previous models, while still ensuring full accountability since each oracle report contains every node’s observation and signature. In the example diagram below, the OCR oracle report only involves one on-chain transaction as opposed to 15 if the aggregation was done on-chain.
Chainlink OCR can be enhanced through the introduction of Chainlink External Adapters. Chainlink External Adapters extend the types of data Chainlink oracle nodes can access and the types of computations they can perform beyond their built-in functionalities. Commonly used to connect to password-protected APIs, Chainlink External Adapters can also define how the oracle performs computations, choosing whether to optimize for privacy, low latency, and/or high throughput. For example, External Adapters enable Chainlink nodes to perform advanced computation like statistical analysis, the calculation of a price index, or machine learning processing. External Adapters can also be used to simply connect a smart contract to computation from an external network such as a Cloud or Big Data system.
The modular nature of External Adapters future-proofs the Chainlink Network by providing developers with a framework to leverage any type of computation for their smart contract that a blockchain or Web 2.0 system cannot provide.
Cross-Chain Interoperability Protocol (CCIP)
The Cross-Chain Interoperability Protocol (CCIP) is an open-source standard in development that establishes a universal connection between different blockchain networks. CCIP is the backbone that powers the creation of secure token bridges and cross-chain applications that move data, assets, and commands across blockchains. Chainlink nodes use oracle computation in the form of OCR 2.0 to read transactions from one blockchain, generate off-chain consensus on their legitimacy, and then transmit the results to another blockchain.
One of the many forms of trust minimization being implemented in CCIP is the Anti-Fraud Network — a DON consisting of nodes separate to those bridging assets and commands across networks. The Anti-Fraud Network uses oracle computation to analyze CCIP networks and immediately initiates a pause if it detects issues in the protocol or connected blockchain network (e.g. reorg events). Importantly, the Anti-Fraud Network is not directly involved in the transfer of funds, but instead acts as a checks and balances layer. The separation of powers between the Anti-Fraud Network and bridges furthers the trust minimization of CCIP by reducing the control any single group can have over its services.
Hybrid Smart Contracts Powered by Oracle Computation
These Chainlink services showcase how trust-minimized oracle computation further extends the capabilities of smart contract applications through a synergistic relationship with blockchains. Oracle computation not only enhances smart contract applications — it can also directly improve the architecture of blockchain networks through computation-enabled services such as Fair Sequencing Services for transaction ordering and layer-2 validation for executing contract code off-chain. Given its flexibility, oracle computation is truly limitless in how it can complement on-chain smart contract logic.
The end result is the proliferation of hybrid smart contracts — decentralized applications that combine tamper-proof code running on a blockchain (on-chain) with decentralized services provided by oracle networks (off-chain) to achieve far more advanced utility. In fact, most successful smart contract applications across DeFi, gaming, NFTs, and more are hybrid smart contracts. For example, DeFi money markets use Chainlink Price Feeds to access external financial market data needed to determine a user’s borrowing capacity and check if outstanding loans are subject to liquidation. DeFi money markets also use Chainlink Automation to trigger liquidation functions precisely when loans are found to be under-collateralized. Combinations of off-chain data and computation extend beyond money markets too, supporting use cases like algorithmic stablecoins, derivatives platforms, prediction markets, NFT platforms, no-loss savings games, and much more.
As the vision presented in the Chainlink 2.0 whitepaper continues to crystallize, oracle computation will play a similar role in enhancing smart contracts as APIs do today in supporting Web 2.0 systems. Developers can leverage different types of oracle data and computation within their application knowing that these services are secure and reliable via various trust-minimization techniques. This will vastly accelerate development time, as teams can focus on their application’s core business logic instead of worrying about building and maintaining off-chain infrastructure. Ultimately, this calls for extending the definition of oracles to entities that provide smart contracts with all the data and computation that they cannot get on their native blockchain in a manner that fits their own trust assumptions, performance needs, and budget.
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.