Even in a sluggish market, the demand for oracles has continued to grow exponentially.
Speech: Frank, Developer Relations Engineer at Chainlink Labs
Edited by: aididiaojp.eth, Foresight News
I am Frank, a developer relations engineer from Chainlink Labs. My main job is to enable more developers or builders who are passionate about this industry to learn more about oracles. Based on the smart contracts under our current infrastructure, we can think of it as a hybrid smart contract. Smart contracts can be better integrated with various data in the Web2 world, including computing services, and then based on this architecture, greatly expand what the on-chain smart contracts can do.
In today’s sharing, I will first introduce the concept of oracle, and then based on the concept of oracle, I will briefly introduce the decentralized oracle network, as well as some services we can provide, including data services and computing services.
What is an oracle?

From Web 1 to Web 2 and then to Web 3, the network and data status are constantly changing. At the beginning, Web1 was a website service where data could only be read statically. When it developed to the Web2 stage, data became readable, writable, and participatory. Many large companies have created business empires based on their own services. They will store all user data in their own databases. If there are some needs, they can actually own and modify user data. Then this will lead to a question, that is, some of the data we create on the Internet or in the virtual world sometimes has some value, so who does this value belong to? Based on this background, we hope to solve this problem well in the Web 3 stage. In the Web 3 stage, all data does not exist in a server or a node. It has a decentralized network, and the decentralized network is a multi-ledger system composed of multiple nodes. Data is stored in multiple nodes. Only when each node agrees to the modification and storage of data can the data be saved in the end. This will bring us a benefit, that is, no matter what kind of modification we want to make to the data, we need to modify it according to the pre-agreed consensus. For example, if I want to modify the balance of my wallet, if no one sends me money, no matter how the owner of the data wants to modify it, he will not be able to pass the consensus process in the end, which means that the balance of the wallet cannot be modified. Only when the owner of the data sends a transaction that complies with the rules can the data be modified in the end. This brings a very obvious benefit. At the same time, it also brings some disadvantages. The biggest disadvantage is that it makes the system a deterministic system. That is to say, because there will be a consensus process in the whole process, it can only perform operations that others can verify. When you send an operation, others need to execute your operation. If other nodes can execute the operation successfully, they can actually return the result. As for whether it exceeds 50% or 70%, this depends on the consensus algorithm.Finally, the operation can be written into the transaction, and the transaction can be written into the block to become a complete transaction.

However, if we need to do some non-deterministic operations, such as obtaining some API data and generating random numbers outside the blockchain, the deterministic blockchain system cannot complete it. We need to generate random numbers for lottery draws, or the on-chain protocol needs to know the asset prices under the chain, such as obtaining the prices of stocks or commodities. This is a non-deterministic operation and cannot be completed by the blockchain itself. For example, if I call an API as a node in the network, I call external API data, and then I tell other nodes in the network the result. In order to verify the authenticity of the result, other nodes will also perform the same operation and get a result. However, for an external API, different people use the same API at different times, and the server may be down, or the service may be suspended, or the data may change over time. You do the same thing at different times, and the results you get are inconsistent. As long as the results are inconsistent, the final operation cannot be entered into the block, and it cannot be completed. This is why we have data ownership, but we also need to bear some of the shortcomings it brings.

To solve this problem, we need to rely on oracles. Blockchain is an isolated and deterministic system. It cannot actively obtain data from the off-chain. The emergence of oracles is to solve this problem. The concept of oracles appeared two or three years ago, but there were not many applicable scenarios at that time, and there were great limitations. For example, if you want to obtain some market data, upload stock data to the blockchain network, or make an architecture to execute logic off-chain, but put the asset side on the chain, and use smart contracts to protect the normal progress of transactions, you need to obtain some data from the off-chain, and need to synchronize data periodically, including bank payment or retail data, and even some other public event data, such as weather conditions, geographical information, logistics information, sports results, etc. These data cannot be obtained without oracles. This will make the on-chain ecology very limited. As the Web 3 ecology continues to develop, the connection between the two worlds of Web 3 and Web 2 will become closer and closer. If we want Web3 to be widely adopted or used by more people, it must provide very rich functions, not just limited to some operations that can only be done through on-chain native data.
Oracle became popular in 2020, when DeFi Summer came, and most people became aware of it. At the beginning, what the oracle did was very simple. For example, if you want to obtain external data and upload it to the decentralized network, that is, the blockchain, the simplest way is to establish a centralized node off the chain, that is, to build a server, and then obtain data through the server, and finally write the data into the deduplicated blockchain network. This model is called a centralized oracle. Although it is relatively simple to implement, it will bring some problems. For example, it has the risk of single point failure, that is, the centralized node may cause downtime due to its own basic reasons. Another possibility is that if the service provided by the on-chain smart contract depends on the data provided by the centralized node, and if the amount of funds involved in the on-chain smart contract is very large, then this centralized oracle may attack the service through the data it can control. As long as the interests are large enough and there is no way to achieve complete protection through technical means, then this is a single point of failure. We want to put the application in a decentralized network, including Ethereum or other Layer 2 ecosystems. In fact, we also hope that we can use hundreds of oracle nodes in the network to ensure the fairness and security of our application, that is, the smart contract.

Of course, if we rely on centralized nodes to obtain data, even if other aspects of security can be guaranteed, if the most important asset data cannot be guaranteed, the entire dApp will lose its meaning. So after the centralized oracle, the decentralized oracle network appeared, which can well solve the risk of single point failure we just mentioned. The biggest difference of the decentralized oracle network is not that a single oracle node provides services to the decentralized network, but that services are provided through the decentralized oracle network. It can also be understood as a kind of Layer 2, that is, each node in the decentralized oracle network can obtain data through its own data source, and after obtaining the results, it can aggregate data with other decentralized networks. It can also be understood as a consensus process, including checking whether there are nodes in the data, or whether the returned data deviates too far from the average, or simply making an average, and then aggregating the data once, etc., and then writing it to the decentralized network. The benefits of this method are that it can technically ensure that the service will not be interrupted unless all nodes in the decentralized oracle network stop serving, but this possibility is very low. In addition, the data side can also ensure that the data provided by the oracle to the on-chain contract is not controlled by a single node, but by multiple nodes. If you want to manipulate the data to launch an attack, the cost is very high, which is equivalent to you wanting to attack Layer 2, or even a decentralized network like Ethereum, which is basically unlikely to succeed.

Decentralized networks can greatly improve the security and fairness of smart contracts receiving data. For users, we are just a decentralized oracle network, but based on the decentralized oracle network, we can provide some other services, such as data services, computing services, and cross-chain services. If the oracle provides data to the network, there are actually some more complex and costly operations that can also be completed off-chain, that is, pack it to the off-chain oracle network for calculation, and then write it back to the blockchain with higher security. If we can get data from off-chain, we can also get data from other chains and write it to this blockchain, which actually involves cross-chain. As long as the decentralized oracle network is secure enough, it can ensure that the security of the data services, computing services, and cross-chain services built on it is very strong. Chainlink provides a variety of services based on decentralized oracles, which can connect the data of Web 3 and Web 2, including the data of Layer 1 and Layer 2, so that everyone can get as much corresponding data and services as possible.
What services does Chainlink oracle provide?
Next, I will briefly introduce the services provided by Chainlink Oracle. Of course, there are many services provided by Chainlink, and I will share some services that are more applicable to various scenarios.
If you want to make some innovations in DeFi, GameFi, NFT, and SocialFi in the future, you will most likely need an oracle to obtain data. Because you must obtain chain data in a very decentralized and secure way and write it back to your on-chain smart contract.
The first service is price feeding, which may be a term that everyone has often heard before. It became popular in the DeFi Summer of 2020. In 2020, many DeFi projects appeared. The first one was Uniswap, followed by the lending contract Compound, and then the synthetic asset project Synthetics and other applications. They all have a large demand for off-chain data, because only secure data can be used by users in a decentralized manner through contracts. The oracle's price feeding service plays an important role in this.

The above figure is a basic flow chart of the price feed service, which includes 3 important participants. The first is the decentralized oracle network we just mentioned; the second is the data provider, which may be an exchange or other large authoritative organization, they can all serve as data providers; the third is the user contract. The process shown in the above figure is very simple. Each data provider can provide it to a node of the Chanlink oracle network through the data source interface or service. Each node of the oracle network can also obtain data according to its own service, and then after the aggregation process, the data obtained from each channel is written to the verification contract deployed on the chain. If the verification is passed, the data can be recorded and can be used by users in the future. This is the whole process. The user end only needs to use the contract to obtain and use multiple data.
There are many use cases for price feeds, such as Compound, Uniswap, and Synthetics, which we mentioned earlier. They need to map assets in Web2 to Web3, and at this time they need external mechanisms to provide asset prices. Just like stablecoins, it can issue as many stablecoins as it can based on the assets, so its asset prices must also be obtained based on oracles. In addition, some asset management platforms and popular derivatives trading applications are highly dependent on prices, so these are actually important users of price feed services. From the trend point of view, the demand for price feed services is rising exponentially. Although the market is not so active, data usage is also growing.

Next, I will introduce the second more distinctive service, Any API. In simple terms, it helps the smart contracts on the chain to obtain some non-standard data, such as some long-tail data. These data may only be available to certain people or certain contracts, but they are not standard data like token prices or asset prices. Many DApps need non-standard data, such as Web 3 insurance business applications that need to obtain weather data or flight delay data. For example, greenhouse gases can do some ESG-like projects, including elections and sports competitions that can be combined with prediction markets. We provide a data market based on Any API. In each data market, there are various data providers that provide services to the outside based on their own data. As long as the user sends a request, he can write the data back to the user contract according to the service requirements. The data provider and the data receiver are determined by the market. There is a market for users and data providers, and it is not that Chainlink officials monopolize all data and then provide data to the chain.

The workflow of Any API is actually quite consistent with that of price feed. The contract first sends a request, which is then discovered by Chanlink's node. After discovery, Chanlink can select the required data based on the request and then write it back to the blockchain. Any API can provide users with a variety of data, but it has a feature that although it is built relatively quickly, it is provided by a single node. What Any API wants to do is to obtain data as quickly as possible in a simple way, rather than obtaining data through the decentralized network oracle we mentioned earlier.

Later, as the diversity of data needs increased, many non-standard data also hoped to be written back to the chain in a decentralized way. We also made a new service called Functions in early April this year. Simply put, it executes any user request through a decentralized oracle network. Users can write operating programs in some advanced programming languages such as Javascript, and no longer have to be written in Solidity. Programs written in Javascript are definitely richer than Solidity. The Functions service can encapsulate the written program into the request and send it to the entire oracle network. Every node in the network will perform the same operation, which may be a computing service, a data acquisition service, or other services. After each node executes and obtains the result, it goes through the aggregation process we just mentioned and is written back to the smart contract.

Compared with price feed, it has a much higher degree of freedom. In other words, it can provide an external interface to the smart contract to use any method it wants. It can also write some of the logic it wants to do into the contract, and then it is not executed by the blockchain, but by the oracle, which is equivalent to embedding the oracle service directly into the smart contract, turning it into a hybrid smart contract. If you do it this way, your execution is guaranteed by the decentralized network, and your non-deterministic operations, which are operations that cannot be done on the blockchain, can be executed through the decentralized oracle network and return results. In general, it can greatly improve the functionality of smart contracts. It can do more functions than before, and it is also very simple to apply on the user side. You only need to add two functions to your contract, and you can directly use the decentralized oracle network as part of your smart contract. And it is also very friendly to traditional Web2 programmers, because the execution logic can be completed through traditional programming languages. The overall process has not changed. Send a request, then give it to the decentralized oracle network, aggregate it after execution, and finally write it back to the user's smart contract.
The above is what I shared about oracles and some of the services that oracle-based decentralized networks can provide.
