Cointime

Download App
iOS & Android

What Is a Blockchain Oracle and How It Automates Smart Contracts

Validated Project

Key Takeaways:

  • A blockchain oracle enables smart contracts to interact with off-chain systems for the effective execution of the contract terms.
  • Blockchain oracles are important since smart contracts living on blockchains cannot access off-chain data.
  • Enabling smart contracts to function using off-chain data feeds improves the value of decentralized applications (dApps). 
  • The oracle problem refers to the concerns that stem from having a decentralized system depend on a centralized system to function. 

​​​​​The word oracle is derived from Greek about an individual who communicates directly with the gods and foresees the future. In ancient times, people had little knowledge about current and future happenings. As such, they relied on oracles to gain knowledge beyond their understanding. In the blockchain context, oracles connect blockchains with the outside world, acting as bridges. 

This guide answers the questions:

  • What are blockchain oracles?
  • How do blockchain oracles work?
  • Why are blockchain oracles important?
  • What is the blockchain oracle problem?
  • What are the types of blockchain oracles?

Let’s get the answers to each of them in the separate sections within this article.

What is a Blockchain Oracle?

A blockchain oracle is a data feed that sources, verifies, and transits off-chain data (data from other blockchains and the outside world) to smart contracts living on the blockchain. In addition to sourcing off-chain data and transmitting it to the blockchain, an oracle can relay data from it to external systems. For example, an oracle unlocks a smart lock once a user makes a payment through a blockchain transaction.

Source: Chainlink

As mentioned, oracles function as bridges, linking on-chain systems, like smart contracts, with off-chain/external data providers. This expands the scope in which smart contracts operate. In other words, smart contracts would have a limited application without blockchain oracles since they would only have access to on-chain data. An oracle presents a mechanism for activating smart contract functions using trusted external data.

Note that a blockchain oracle isn’t the data source. Instead, it is the system that queries, confirms, and authenticates off-chain data sources, and then transmits that information to a blockchain network. The transmitted data can be the price and exchange rates of assets, natural disasters and risk measurements, statistics, dynamic data (time measurement), political activities, games, geolocation and tracking data, events in other blockchains, etc. 

How Do Blockchain Oracles Work?

Generally, an oracle consists of a smart contract operating on-chain and some off-chain elements. The contract receives requests for data from other on-chain applications and relays them to the off-chain part (known as an oracle). The oracle node can query data sources primarily through Application Programming Interface (APIs), relay the extracted information, and store it on the blockchain.

Here's an example of how a blockchain oracle works:

Suppose Alice and Bob bet on the outcome of the 2024 US presidential election. Alice is firmly convinced of a Republican candidate win, while Bob is for a Democrat win. They set clear terms and conditions about the bet and lock their stakes in a smart contract. The smart contract will release the funds to the winner after the 2024 election results are announced.  

Remember, the smart doesn’t know what is happening off-chain – in this case, the 2024 US presidential election outcome. When the set timeline reaches or after the election, the oracle queries a trusted API to know the candidate that won and transmits the information to the blockchain. The smart contract then uses the relayed information to release the funds to the winner. 

Without the oracle querying and transmitting the information on-chain, there would be no effective way to settle the bet freely and fairly.

Why Are Blockchain Oracles Important?

Most cryptocurrency users view smart contracts as lines of code operating at specific addresses on the blockchain. These smart contracts are self-governing computer programs capable of executing agreements between parties once the predetermined conditions are met – hence the reason why they are called “smart contracts.” 

However, using smart contracts to execute agreements between parties in deterministic systems, like the blockchain, is a complex issue. A deterministic system always produces expected results under a static state and particular input – there is no variation in computing outputs from inputs. To ensure deterministic execution, blockchains only need to form consensus on basic binary questions drawing on data that is already stored in its ledger. Examples of binary questions include:

  • “Did the wallet owner (identified by a public key) approve this transaction with the right private key?”
  • “Does this wallet have adequate funds to transact?”
  • “Is the transaction binding in the context of this smart contract?”

If blockchains source information from off-chain systems, determinism would be challenging. As the off-chain data mayu change often, this limits nodes from reaching a consensus on the legitimacy of changes to the blockchain’s state. For instance, consider a smart contract executing a transaction based on the current BTC-USDT exchange rate sourced from a standard price API. The figure would probably fluctuate often, besides the risk of the API getting hacked or corrupted. This means nodes performing the same contract code would produce different outputs.    

Determinism is integral for any public blockchain, with numerous nodes spread worldwide. Since no central authority acts as a truth source, we expect the nodes to produce similar results from the duplicate transactions. A scenario where node A performs a smart contract code and arrives at “4” as the output, while node B arrives at “10” after completing the same transaction would break down the blockchain’s consensus and value as a distributed computing system. 

The above example also demonstrates the problem with allowing blockchains to source information from off-chain sources. Nevertheless, oracles solve this problem by “pulling” information from external sources and relaying it to blockchains for use in smart contracts. Since on-chain data is immutable and publicly accessible, this lets blockchain nodes securely utilize off-chain data to make changes without breaking consensus. 

The Blockchain Oracle Problem

The blockchain oracle problem relates to sourcing external data onto a blockchain. It’s important to ensure this data is correct – else, smart contracts will use erroneous inputs to produce incorrect outputs. Since smart contract transactions are irreversible, we must ensure that the oracle input is correct. Imagine a smart contract releasing a $100 million bet to the wrong winner because of an incorrect input! That will be catastrophic, considering that the smart contract is immutable and that the users' identities are hidden.

The other issue is that oracles (particularly centralized oracles) can act as a central point of failure, vulnerable to hacks and manipulations. This could cause smart contracts to execute incorrectly, leading to unintended consequences. Additionally, using oracles can introduce trust issues, as users have to trust that the oracle is providing accurate information.

However, there are ways of addressing the blockchain oracle problem. One is using multiple oracles to provide the same data, increasing the chances of getting accurate information. The second solution is using decentralized oracles, ensuring the use of tamper-proof data. As the adoption of blockchain technology continues to grow, new solutions to the blockchain oracle problem will likely be developed.

Types of Blockchain Oracles

Source: Chainlink

Oracles can be grouped into two broad categories: centralized and decentralized. Let’s discuss them separately, including their advantages and disadvantages.

Centralized Oracle

A centralized oracle is a system that serves as a single source of truth for data or information needed by a blockchain network. The oracle acts as an intermediary between the blockchain and the external world, providing information to smart contracts on the blockchain as required. 

A centralized oracle typically operates on a server or set of servers and is controlled by a single entity or organization. It is responsible for collecting data from various external sources, such as APIs and web scraping, and then formatting and transmitting the data to the blockchain. Provable is a typical example of a centralized oracle.

Advantages

Faster data retrieval: Centralized oracles can use specialized methods to retrieve data from trusted sources quickly.

Greater control: With a centralized oracle, a single entity controls the data fed into the smart contract, stamping more authority into the sourced data (especially when the entity is highly trusted).

Scalability: Centralized oracles can handle many requests, making them suitable for large-scale applications.

Disadvantages

Single point of failure: Since a single entity controls a centralized oracle, it can become a single point of failure for the system.

Lack of transparency: The data provided by a centralized oracle may need to be fully transparent, making it difficult for users to verify the accuracy of the information.

Centralized control: The centralized control of the oracle makes it highly vulnerable to censorship and goes against the decentralized aspect of smart contracts.

Decentralized Oracle

A decentralized oracle is a system that allows smart contracts on a blockchain to access external data securely. It works by using a network of nodes to collect and validate data from external sources and then uses a consensus mechanism to agree on the accuracy of that data.

Examples of Decentralized Oracles

Chainlink is the biggest decentralized blockchain oracle by market cap. It is built on Ethereum and uses a decentralized network of independent nodes to source data from various sources, such as APIs. Then it uses a reputation system and a consensus mechanism to ensure the accuracy and reliability of the data. Blockchain smart contracts then use the data to execute the terms of the contract.

Band Protocol is the second-largest decentralized blockchain oracle by market cap. It is built on Cosmos with cross-chain functionalities, and uses a decentralized oracle network to fetch data from various providers and delegated proof-of-stake (DPoS) to ensure that the data is accurate. The oracle contract uses the data to execute the terms of the contract.

Advantages

No single point of failure: A decentralized oracle is less likely to be compromised or shut down since a single entity does not control it.

Transparency: Transactions on a decentralized oracle are recorded on a public ledger before transmitting and storing them on a blockchain.

Censorship resistance: A decentralized oracle is censorship-resistant because a central authority does not control it.

Tamper-proof: Data stored on a decentralized oracle is secured using cryptography, making it tamper-proof.

Disadvantages 

Complexity: Decentralized oracles can be more complex to set up and run than centralized oracles.

Scalability: Decentralized oracles can be less scalable than centralized oracles because they rely on a distributed network of nodes.

Conclusion

Blockchain oracles expand the capacities of smart contracts by offering access to off-chain resources integral in harnessing useful and enhanced hybrid smart contract applications. Like how the internet presented radical changes to information sharing, oracle-based smart contracts are revolutionizing how people exchange value and execute automated contractual agreements. 

Comments

All Comments

Recommended for you

  • BTC breaks through $69,000

     the market shows BTC breaking through $69,000, currently at $69,021.49, with a 24-hour increase of 1.15%. The market is highly volatile, please manage your risk accordingly.

  • Spanish Foreign Minister: Not worried about any consequences of refusing US access to military bases

     on March 3 local time, Spanish Foreign Minister Alvarez defended the Spanish government's refusal to provide the Rota and Moron military bases to the United States for participation in attacks on Iran. Alvarez stated that the operation initiated by the United States and Israel is not supported by the United Nations and is not part of the bilateral agreements allowing the use of the aforementioned Spanish sovereign military bases. Alvarez also said that the Spanish government is not concerned that this stance will have any consequences. Alvarez stated: "The position of the Spanish government represents the will of the vast majority of the Spanish people as well as the vast majority of people worldwide, which is to defend the UN Charter, respect international law, and believe that cooperation is always more powerful than confrontation."

  • Spot gold plunges nearly $100 in the short term.

     spot gold plunged nearly 100 dollars in a short time, spot gold fell below 5170 dollars/ounce, with a daily decline of 2.94%. 

  • BTC falls below $67,000

    the market shows BTC fell below $67,000, currently at $66,996.93, with a 24-hour increase of 1.18%. The market is highly volatile, please manage your risk accordingly.

  • ETH breaks $2,000

    the market shows ETH breaking through $2000, currently at $2001.64, with a 24-hour increase of 2.89%. The market is highly volatile, please manage your risks accordingly.

  • The US spot Bitcoin ETF saw a net inflow of $962.48 million yesterday.

    according to Trader T's monitoring, the US spot Bitcoin ETF had a net inflow of 962.48 million USD yesterday.

  • BTC falls below $66,000

     the market shows BTC fell below 66,000 USD, currently at 65,986.66 USD, with a 24-hour decline of 1.31%. The market is highly volatile, please manage your risks accordingly.

  • BTC falls below $66,000

     the market shows BTC fell below $66,000, currently at $65,973.16, a 24-hour drop of 2.66%. The market is highly volatile, please manage your risks accordingly.

  • ETH breaks $2,000

    market shows ETH breaking through $2000, currently at $2000.29, with a 24-hour increase of 3.73%. The market is volatile, please manage your risk accordingly.

  • The United States uses Anthropic's artificial intelligence technology in its airstrikes in the Middle East.

     United States used Anthropic's artificial intelligence technology in airstrikes in the Middle East, and just hours before the attack, Trump had just issued a ban against Anthropic.