Why do we need Oracles?
The first generation of blockchain networks was able to transfer value from
Alice to Bob. They can be perceived as transaction networks. The second generation came with smart contracts. It enables us to work with conditions. It is very useful in an environment where people do not trust each other and it is needed to be sure that something is true before coins or tokens are transferred from one person to another. Decentralized Finance (DeFi) can take the whole concept even further and link the purely digital world of blockchain with the physical world. We are talking about the physical world but the world of traditional finance is to a certain extent digitized as well. The goal of the blockchain movement is to transform traditional finance products into decentralized, trustless, and transparent protocols. It will be possible when we can feed data from the external world into decentralized applications. It must be ensured that data from the real world is reliable. Which data are we talking about? It can be anything that comes to your mind. For example, prices of other digital assets, currency or commodity exchange rates, results of events like voting or election, delays of planes, ownership of properties, temperature, facts, results of asset transfers in the traditional financial systems, etc.
People live and interact with each other in the physical world. We can create a great digital cryptocurrency but if we want to use such currency in a decentralized fashion then it must work reliably in the physical world for many sorts of interactions. We want to use cryptocurrencies for buying goods on the internet and it must work in the case that a buyer does not trust a seller and vice versa. People might want to buy digital assets for fiat currencies on a decentralized exchange, so the current exchange rate must be known. There must be a reliable source of truth for services like insurance against delayed flight, for buying physical property, or betting on a result of an election. In some cases, the real identity of persons must be known. It is fine to stay anonymous when you wish to. If we wanted to build lending services that would work without digital collateral, then the real and verified digital identity of borrowers come in handy.
There are plenty of interactions that happen between people and in many cases, a pure transactional blockchain network is not able to ensure a required level of truth and reliability. In the next few decades, we will probably not use paper for contracts, shares, proof of ownership for things like cars or houses, university diplomas, etc. All that will be digitalized and the question is who will be authorized to work with these pieces of information. We are used to the idea that authorities and institutions are the only entities that can do that. It might seem that it will be like that forever and it will never be possible to do that in a decentralized way. Let’s ask a simple question. Why not if we are able to do that from a technological point of view. If we really believe that decentralization is a game-changer then we must strive to be technologically ready for the change.
If you asked what is currently the most useful usage of Oracles then it would be stable coins. Stable coins are tokens issued on a platform and their value is the same as for example USD. DeFi can offer many advantages over traditional finance. DeFi is about decentralization and extends the concept. Thus, censorship-resistance, openness, and global accessibility are the key features. Financial services, however, require price stability. Due to the stable coins, we are able to build services that will be decentralized and the volatility will not be an obstacle to usage. A global decentralized lending service without the need to deal with the volatility of crypto assets would be awesome. Combined with digital identity and other services, such services could become real competitors to the traditional bank services. People often think that we can build that around volatile assets like ADA, BTC, or ETH. In our view, people will not use these volatile assets for payments in the foreseeable future. Why should they use them for lending if it is even more dangerous? There is no fixed link between decentralization and volatile assets. We need to build services that will not require buying native coins of platforms on which the services run. People will just want to use financial services via stable coins. That is all. Decentralization and price stability will be the necessity for modern financial services.
Oracle services are the way how we can push blockchain technology one level up.
What exactly is Oracle?
Put it simply, Oracle is a service that provides smart contracts with data from the real world. Oracles are operated by third parties that are economically incentivized to ensure reliable services.
If there is an agreement between participants, that is realized via a smart contract, then execution of the contract relies on the events that happen in the real world. Oracle is the bridge between the real world and the execution of the smart contract. The smart contract can be written in a way that it will make decisions based on the expected events in the real world. There is on-chain data that is managed by the blockchain itself. It can be coins and tokens at a given address. A smart contract, that is executed on-chain, is able to move coins from one address to another. A condition can be defined that dictates transferring of coins from the address of Alice to the address of Bob in the case that some particular event in the real world comes true. Events in the real world are off-chain data. Neither blockchain nor smart contracts are not able to read or verify events in the real world. In other words, they do not have access to off-chain data. Oracles are able to read the off-chain data and transform it into on-chain data that can be consumed by smart contracts.
Oracles are the eyes and ears of blockchain. They observe the real world (off-chain data) and translate it into the digital form that can be used by smart contracts. Off-chain data are consumed in the form of on-chain data.
As an example, let’s imagine that Alice is a fan of Liverpool FC and Bob is a fan of Manchester United. The clubs are going to play a match against each other next weekend. Alice and Bob bet 1000 ADA coins to the win of their favorite club. They decided to use a smart contract for the bet. They lock 1000 ADA and wait for the result of the match. The smart contract can work only with on-chain data. It is able to lock ADA coins and pay off the winner when the result is known. All conditions are defined on-chain in the smart contract. However, the smart contract is not able to find out the result of the match. It is off-chain data. Now, the Oracle comes into play. The Oracle knows the result of the match. Thus, it translates it into the on-chain form and provides it to the smart contract.
There are conditions in the smart contract that can be phrased like “did Liverpool won?” and “did Manchester United won?”. Let’s assume that Liverpool won 3:2. The Oracles translates the result of the match into two boolean values that are provided to smart contracts. The values are “true” and “false”. The smart contract is able to work with boolean values and know that Alice is the winner and Bob the loser. Thus, it is able to send Alice back her locked 1000 ADA and also Bob’s 1000 ADA. In the case that the match would end up by draw, the Oracle would translate that into two same boolean values. For example, it would provide a smart contract with values “false” and “false”. Nobody won in this case and the smart contract would send back locked coins to both Alice and Bob.
Oracles themselves are not sources of data. Oracles are entities that are connected to external data sources, process them, and then send them to smart contracts. Oracles are bridges between blockchain platforms and the real world. They sit in the middle, observe data that are required by smart contracts, and are able to provide them. The people behind Oracles have to find relevant sources of data, find a way on how to consume them, authenticate them, verify them, possibly aggregate them and then send them to smart contracts in time and in an expected format.
The way of transferring data might not necessarily be only from the real world to smart contracts. It can work the other way round and the result of a smart contract can be transferred into the real world. Moreover, a traditional bank can want to have a reliable source of information about blockchain addresses and transactions without the need to operate their own full nodes.
Decentralization and incentives
If I asked 100 randomly selected people about the result of the match between Liverpool and Manchester United then I would very probably get the correct answer. People would be able to find the answer if they were economically incentivized to do so. They would not probably lie if they could be penalized for incorrect answers. 95 people would answer that Liverpool won. 3 persons would answer that Manchester United won and 2 persons would not be able to find the correct answer. Based on all answers, it is an easy task to conclude that Liverpool won the match.
I have just got the answer in a decentralized way. Let’s assume that I am an operator of an Oracle service. I know the correct answer thus I can provide the information to the smart contract that has been deployed by Alice and Bob. Have you noticed something wrong there regarding decentralization? The answers were collected in a decentralized way, however, the provision of the information to the smart contract was centralized.
When an Oracle is controlled by a single entity and it is the only provider of the information then it is a centralized service. I could not bother asking 100 people and I could do it myself by reading a newspaper. If Bob was my friend, I could provide false information and claim that Manchester United won. If I got sick then I could forget to answer and the smart contract would give back 1000 ADA to Alice and Bob since it could not make a decision about the winner.
A centralized service is not a reliable source of service. It is risky from a smart contract’s point of view to rely solely on a single provider of information. Any malicious behavior of the owner would directly influence the result of smart contracts. Moreover, it is a single point of failure and hackers could easily attack it.
To make the execution of smart contracts more resilient it is needed to use a certain number of independent Oracle services. How many? It depends on the situation. A simple answer could be that the more value is handled by a smart contract the more reliability is required.
How to ensure the reliability of Oracles? Notice that provision of information from the real world is similar to the network consensus. Pool operators are motivated to provide good service since they are paid for that. Even if there are bad actors in the network the good actors always win under the condition that the majority of actors are good actors. It works fine within the network consensus. It can work in a similar way for Oracles. Smart contracts can be able to consume data from more sources and aggregate results. It can be perceived as a kind of consensus upon data.
Oracle operators will be rewarded for good service and they can be penalized for providing not precise data, providing them late or not at all. A reputation system can be built to help smart contract developers better choose good data providers. Users of smart contracts will have to pay not only for the processing of on-chain data but also for retrieving off-chain data. It means that the fee will be split into more baskets and a part of the fee will be given to Oracles operators. A condition can be defined that Oracles operators need to lock a certain amount of coins. A part of the coins can be slashed when an Oracle fails to provide a good service. Decentralization of Oracle services will probably increase with building new services that use smart contracts. Being an Oracle operator can be a profitable business and new ones will come. Trust and reliability will increase with the number of services and competition between them.
Oracles in the Cardano ecosystem
Emurgo is one of three official entities behind Cardano. Emurgo in cooperation with the project Ergo came with the concept of Oracle pools.
Oracle pool is a group of Oracles that provide the same data. Oracles provide inputs and the pool aggregate the inputs to create a single output. The output can be sent to a smart contract or to another Oracle pool that is higher in the hierarchy. Every Oracle pool can provide data in regular time intervals. The time respects a given blockchain. Thus the time is measured in blocks or slots.
Oracle pool provides data periodically in epochs. In every epoch, data received from all Oracles are collected, averaged and one output is created. New outputs are produced every epoch. Every Oracle pool has a posting price. It is the price of a created output. Oracle pool produces outputs only in the case that it is well funded. Always when new output is posted by an Oracle pool the posting price is withdrawn from the fund of the pool and it is distributed to all Oracles that provided accurate data in a given epoch. When an Oracle fails to provide data timely or data are inaccurate then the Oracle is not rewarded. Such Oracle can be even penalized. To join a pool, a stake might be required by the Oracle pool. It can ensure that Oracle operators join an Oracle pool only in the case they are sure that they can reliably provide data.
Oracle pools must be well funded in order to produce outputs. When a fund is below posting price then Oracles do not post data to the pool. The Oracle pool itself is not able to provide outputs since it does not have a sufficient number of inputs from Oracles.
An Oracle that will be able to process a required number of inputs as the first one in a given epoch and posts the output will be paid double. Thus, all Oracles are incentivized to race among each other and post data as the first one in order to get the double reward. This mechanism ensures that the output will be posted timely in every epoch since there are more Oracles that want to win the reward.
To add more trust and reliability, a complex hierarchy of pools can be created. For example, there can be more Oracle pools (Tier 1) that will provide outputs to other pools (Tier 2). A smart contract developer can decide to consume data only from tier 2. The principles are the same. Pools from Tier 2 race to provide data as the first one. You can imagine tier 2 as a pool of Oracle pools.
The advantage of the pool concept is the fact that every decentralized application or smart contract in the Cardano ecosystem can consume data from Oracle pools. Big Oracle pools can be created and data will be highly accurate as many Oracles will try to participate in providing data. Data from pools will be publicly available to everyone in the ecosystem. A small decentralized application for a few users can benefit from pools. When a given type of data is consumed by many small applications the Oracle pools will be well funded. Developers can create an application that can consume Oracle data and users will pay a negligible fee to use it. Oracle pools will be part of the Cardano infrastructure and they will be available to everybody.
Oracles enable the connection of blockchain with data that are under the control of authorities. The technological abilities themselves do not ensure that it will happen. In some states, it will probably never happen. In some others, we can imagine that. Developing countries might be more willing to use blockchain technologies just for the reason that they do not have a similar infrastructure or they wish to improve it. When the technology is ready the regulations will be the biggest obstacle. It is something that can be discussed and authorities will be willing to explore possibilities of blockchain technologies when they see many successful implementations of similar services. If we manage to create decentralized lending then gates will be open for other services that we cannot even imagine right now. Smart contracts technology has already enhanced blockchain abilities. Oracles will be another step towards a decentralized future.
Source: Oracles in the Cardano ecosystem