Chainlink Engineer: How Oracles Connect Web2 and Web3

Chainlink Engineer: Connecting Web2 and Web3 with Oracles

Despite the market downturn, the demand for oracles has continued to grow exponentially.

Speaker: Frank, Developer Relations Engineer at Chainlink Labs

Compiled by: aididiaojp.eth, Foresight News

I am Frank, a developer relations engineer at Chainlink Labs. My main job is to help more developers or builders who are passionate about the industry to better understand the knowledge about oracles. Based on our current infrastructure of smart contracts, we can consider it as a hybrid smart contract. Smart contracts can better integrate various data in the Web2 world, including computing services, and then greatly expand what can be done by on-chain smart contracts based on this architecture.

In today’s sharing, I will first introduce the concept of oracles, and then based on the concept of oracles, I will briefly introduce the decentralized oracle network and some services we can provide, including data services and computing services.

What is an oracle?

The network and data status is constantly changing from Web 1 to Web 2 to Web 3. At the beginning of Web1, it was a website service where data could only be read statically. When we developed to the Web2 stage, data became readable, writable, and participatory. Many big companies created their own business empires based on their services. They store all user data in their own databases. If necessary, they can actually own and modify user data. This leads to a problem. Some data we create on the Internet or in a virtual world has some value. So who does this value belong to? In this context, 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 is 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 with the modification and storage of the data, the data can be stored. This brings 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 the wallet, if no one sends me money, no matter how the owner of this data wants to modify it, he will not pass the consensus process, which means that the balance of the wallet cannot be modified. Only when the data owner sends a transaction that meets the rules can the data be modified, which 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 is a consensus process in the whole process, it can only execute operations that others can verify. When you send an operation, others need to execute your operation. If other nodes can execute the operation successfully, it can actually return the result. As for whether it is more than 50% or 70%, it 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 perform some non-deterministic operations, such as obtaining API data and generating random numbers outside the blockchain, deterministic blockchain systems cannot complete them. We need to generate random numbers for the lottery, or the on-chain protocol needs to know the off-chain asset prices, such as obtaining the prices of stocks or commodities, which are non-deterministic operations that cannot be completed by the blockchain itself. For example, API calls. If I, as a node in the network, call external API data and then 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, if different people take the same API at different times, the server may hang up, or the service may be suspended, or the data may change over time. If you do the same thing at different times and get different results, the final operation cannot be included in the block, and it cannot be completed. This is because after we have ownership of the data, we also need to bear some shortcomings that it brings.

To solve this problem, it is necessary to rely on an oracle. The blockchain is an isolated and deterministic system that cannot actively obtain data from off-chain. The emergence of oracles is to solve this problem. The concept of oracles appeared two or three years ago, but at that time there were few applicable scenarios and there were many limitations. For example, to obtain some market data, upload stock data to the blockchain network, or do an architecture to execute logic off the chain, but the asset side is on the chain, and normal transaction protection is achieved through smart contracts, etc. At this time, it is necessary to obtain some data from off-chain, and periodic data synchronization is required, including bank payment or retail data, and even some other public event data, such as weather conditions, geographical information, logistics information, sports game results, etc. These data cannot be obtained without an oracle. This will greatly limit the on-chain ecology. As the Web3 ecosystem continues to develop, the connection between the Web3 and Web2 worlds will become closer and closer. If we want Web3 to be widely adopted, or to be used by more people, it must provide very rich functionality, not just limited to operations that can be done through native on-chain data.

The rise of oracles began in 2020, during the DeFi Summer, when most people became aware of them. At first, oracles did very simple things, such as wanting to obtain external data and upload it to a decentralized network, which is blockchain. The simplest way to do this is to set up a centralized node off the chain, which is to build a server, and then obtain the data through the server, and finally write the data into the de-duplicated blockchain network. This mode is called a centralized oracle. Although it is relatively easy to implement, it can bring some problems, such as the risk of single-point failure, that is, the centralized node may crash due to its own basic reasons. There is also a possibility that if the service provided by the on-chain smart contract relies 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 be able to attack the service through the data it can manipulate. As long as the interests are large enough, if there is no way to ensure complete integrity through technical means, this is a single-point failure. We want to put the application in a decentralized network, including Ethereum or other Layer 2 ecosystems, in order to ensure the fairness and security of our application, that is, the smart contract, through hundreds or thousands of oracle nodes in the network.

Of course, if we rely on centralized nodes to obtain data, even if the security in other aspects can be guaranteed, if the most important asset data end cannot be guaranteed, the entire dApp will lose its meaning. Therefore, after the centralized oracle, a decentralized oracle network appeared, which can well solve the risk of single-point failure mentioned just now. The biggest difference of the decentralized oracle network is not that a single oracle node provides services to the decentralized network, but that it provides services through the decentralized oracle network. It can also be understood as a certain Layer 2, that is, each node in a decentralized oracle network can obtain data from its own data source, and after getting the results, it can aggregate data with other decentralized networks. This can also be understood as a consensus process, including checking whether there are nodes for data, or whether the returned data is too far from the average, or simply doing an average and then aggregating the data and writing it to the decentralized network. The advantage of this method is that technically, it can ensure that the service will not be interrupted, unless all nodes in the decentralized oracle network stop providing services, but this possibility is very low. In addition, at the data end, it can also ensure that the data provided by the oracle to the on-chain contract is not controlled by a single node, but by many nodes. If you want to manipulate data to launch an attack, the cost is very high, which is equivalent to attacking Layer 2, or even decentralized networks like Ethereum, which is basically impossible 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 other services, such as data services, computing services, and cross-chain services. If it is based on the oracle to provide data to the network, there are actually some more complex and costly operations that can be completed off-chain, which is to package it to an off-chain oracle network for calculation and then write it back to the blockchain with higher security. If we can obtain data from off-chain, we can also obtain data from other chains and write it to this blockchain. This actually involves cross-chain. As long as the security of the decentralized oracle network is strong enough, it can ensure that the security of the data services, computing services, and cross-chain services established on it is very strong. Chainlink provides various services based on decentralized oracles, which can connect Web 3 with Web 2 data, including Layer 1 and Layer 2 data, and enable everyone to obtain corresponding data and services as much as possible.

What services does Chainlink oracle provide?

Next, I will briefly introduce the services provided by the Chainlink oracle. Of course, there are many services based on Chainlink, and I will share some services that are more applicable.

If you are going to innovate in the fields of DeFi, GameFi, NFT, and SocialFi in the future, you will probably need an oracle to obtain data. Because you must need to obtain chain data in a very decentralized and secure manner and write it back to your chain smart contract.

The first service is price feed, which may also be a term that many people have heard frequently before. Its popularity exploded in the 2020 DeFi Summer. Many DeFi projects emerged in 2020. The first was Uniswap, followed by Compound, which provides lending contracts, and then synthetic asset project Synthetics and other applications, all of which have a lot of demand for off-chain data, because only based on secure data can data be used by users in a decentralized manner through contracts. One of the important roles played here is the price feed service of the oracle.

The above figure is the basic process diagram of the price feed service, which includes three important parties. The first is the decentralized oracle network we mentioned just now; the second is the data provider, which may be an exchange or other large authoritative organizations, which can all serve as data providers; the third is the user contract. The process shown in the figure is very simple. Each data provider can give data to a certain node in the Chanlink oracle network through a data source interface or service. Each node in the oracle network can also obtain data based on its own services, and then after the aggregation process, write the data obtained from each channel to the verification contract deployed on the chain. If it passes the verification, the data can be recorded and can be used by users in the future. This is the entire process. Users only need to use contracts to obtain and use multiple data.

The use cases of price feeding are very diverse, such as Compound, Uniswap and Synthetics that need to map assets from Web2 to Web3, and thus require external mechanisms to provide the asset prices. Stablecoins, for example, are based on how much assets can produce how many stablecoins, so their asset prices also need to be obtained based on an oracle. In addition, some asset management platforms and popular derivative trading applications are highly dependent on prices, so they are important users of price feeding services. From a trend perspective, the demand for price feeding services is increasing exponentially. Even in less active market conditions, the usage of data is constantly increasing.

Next, I will introduce the second unique service, Any API, which helps on-chain smart contracts to obtain some non-standard data, such as some long-tail data. This data may only be useful to certain people or certain contracts, but it is not standard data like token prices or asset prices. Many DApps require non-standard data, such as Web 3 insurance applications that need to obtain weather data or flight delay data. Greenhouse gases can be used for projects similar to ESG, including combining election sports with prediction markets. We provide a data marketplace based on Any API, where each data marketplace has various data providers that provide services to the outside world based on their own data. As long as the user sends a request, it can write the data back to the user’s contract according to the service requirements. The provider and receiver of the data are determined by the market. Users and data providers exist in the market, and Chainlink does not monopolize all the data and provide it to the chain.

The workflow of Any API is actually similar to that of price feeding. The contract first sends a request, and the request will be discovered by the Chanlink 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 various types of data, but it has a characteristic that although it is built quickly, it is provided by a single node. What Any API needs to do is to obtain data as quickly as possible through a simple way, rather than obtaining data through the decentralized network oracle we mentioned earlier.

Later, as the diversity of data demands increased, many non-standard data also hoped to be written back to the chain in a decentralized manner. In early April this year, we also did a new service called Functions, which is simply to execute any user requests through a decentralized oracle network. Users can write the operation program with some advanced programming languages such as Javascript, instead of only being able to write in Solidity language. Programs written in JavaScript are definitely more abundant 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 execute the same operation, which may be a computing service, a data acquisition service, or other services. After obtaining the results from each node and going through the aggregation process mentioned earlier, the results will be written back to the smart contract.

Compared with the feed price, its freedom is very high. That is to say, it can provide the smart contract with any interface it wants to use. It can also write some of its logic into the contract, and then it is not executed by the blockchain, but by the oracle. It is equivalent to directly embedding the oracle service into the smart contract and becoming a hybrid smart contract. If you do it in this way, your execution is guaranteed by a decentralized network, and these non-deterministic operations that cannot be done on the blockchain can be executed through a decentralized oracle network and return results. Overall, it can greatly enhance the functionality of smart contracts. It can do more than before, and it is very easy to use 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. 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, sending requests, then giving them to a decentralized oracle network, executing them, aggregating them, and finally writing them back to the user’s smart contract.

The above is my sharing about oracles and some services that decentralized networks based on oracles can provide.

Note: Blocking all articles only represents the author’s point of view and does not constitute investment advice
Original link: https://www.bitpush.news/articles/4447990

We will continue to update Blocking; if you have any questions or suggestions, please contact us!

Share:

Was this article helpful?

93 out of 132 found this helpful

Discover more

Bitcoin

US Government Seizes $130 Million Worth of Bitcoins from Silk Road: What You Need to Know

The US government has successfully seized Bitcoin assets associated with the notorious Silk Road marketplace in two s...

Bitcoin

Solana’s DEX Volume Soars, Challenging Ethereum’s Dominance ☀️💥🚀

In the past year, Solana's DEX volume market share has seen a remarkable increase, reaching an impressive 28%, while ...

Market

Get Ready for a Wild Ride as Binance Lists ORDI Ordinals with the Magic of Seed Tags

Binance's new listing of ORDI token includes a Seed Tag, indicating a higher level of risk and volatility compared to...

NFT

Trump Sells Off Ethereum: Is He Divesting or Pivoting to Solana?

During the past three weeks, former US President Donald Trump has successfully sold Ethereum (ETH) for $2.4 million, ...

Market

Coinbase and Ether Tokens: Soaring to New Heights with BlackRock’s ETF Application

A potential BlackRock spot ether ETF filing has sparked movement in Coinbase shares and ETH liquid staking platform t...