Smart contracts are software codes that run on a blockchain network (such as Ethereum ) and perform operations or tasks based on specific events. Suppose I want to make a transaction. In the transaction, I provide the recipient’s address and proof that I own and own network funds. If all goes well, the network will “transfer” the funds to the recipient.
What if I want to create a decentralized application that requires external data, such as the current weather temperature, the price of Ethereum, or even the results of baseball games?
How does a smart contract, in other words, a piece of code on the blockchain obtain this information? This is where the oracle of blockchain applications comes in.
The term “oracles” literally means a reliable source of information. Therefore, a dictionary can even be regarded as an oracle. However, we want to avoid unreliable information, so we introduce redundancy. However, we also consider gas costs. The natural gas cost of the 3 external data sources is 3 times the normal natural gas cost. Therefore, we can take the average or median value.
What is an oracle?
The oracle can be seen as an off-chain platform that transmits data on the chain. It is also an off-chain platform that connects the blockchain with other systems. It is the responsibility of the oracle to forward data from the web server to the blockchain. Except for DEX, most decentralized applications use oracles.
In order to obtain reliable data and avoid single points of failure or prevent malicious oracle nodes, we sometimes choose to use redundancy. We introduce more nodes. For example, if we want to provide collateral for DeFi loans, we want the price of ETH from multiple sources , and the borrower deposits ETH as collateral.
Oracles help relay off-chain data
The smart contract on the blockchain cannot simply select information from any data source (such as a web server), because all nodes need to be able to independently verify the results of running the smart contract. When this happens, they are likely to get different results.
For example, the price feed of Bitcoin on different exchanges is different. Even checking the same source at different times will get different results. How do we know which number is accurate, or which number to choose? We usually choose redundant results.
What types of oracles are there?
We classify oracles according to three aspects: the source of the information, the direction of the information, and the degree of trust.
The data source can be hardware or software. The hardware oracle directly collects data from the physical world, converts it into digital value, and then enters it into a smart contract. These include barcode scanners and sensors, which actively or passively collect data and transmit it to smart contracts.
Software oracles obtain information from online resources and browse their websites to provide the latest information for smart contracts. For blockchains, this information usually comes from cryptocurrency exchanges.
The direction of the information can be inbound or outbound. Inbound oracles allow the network to send information from external data sources to smart contracts, while outbound oracles allow smart contracts to send data to external data sources.
As a single entity, the centralized oracle provides data from external sources to smart contracts with a set of security features. However, because there is only one node in charge—similar to a traditional financial system with a single point of failure—it becomes less secure and more susceptible to damage and attack by malicious data entered into smart contracts.
On the other hand, decentralized oracles rely on multiple external sources to increase the credibility of data provided to smart contracts. The decentralized oracle is based on the Schelling point game theory. In the Schelling point game theory, all participants do not collude with each other and provide data. After filtering any inaccuracies, the Schelling game determines the consensus data point or proposes to the software Whether the correction is effective and acceptable.
Believe in oracles
Due to a single point of failure, we need to trust the oracle, which has always been a worrying issue. The essence of blockchain is to eliminate the need for trust intermediaries and eliminate single points of failure. We can alleviate this concern by allowing multiple independent oracles to form a consensus.
This led to the creation of oracle services, which can obtain information from various sources. These resources include large companies such as Google and Amazon, as well as other organizations such as weather stations. This ensures that the results are more reliable than a single source.
Provable is an oracle service that can help developers when they need to consult reliable data sources outside the blockchain. It provides an encryption guarantee for the authenticity of the data.
Should I use an oracle service or a data source?
There are a large number of data sources on the Internet. Therefore, it becomes a challenge to integrate a single application directly into the data feed. This is where the oracle service is useful. They abstract the information from both parties, making it easier for applications to obtain the required data feed.
Use oracle DeFi protocol
Open lending protocols, such as MakerDAO, Compound, and Aave, use oracles to obtain external data when running on the Ethereum blockchain. MakerDAO is one of the most popular DeFi open lending protocols. Its Dai token is pegged to the U.S. dollar and backed by crypto assets.
MakerDAO uses an oracle module to determine the real-time price of assets. This module consists of the whitelist address of the oracle and an aggregator contract. The prediction opportunity periodically sends price updates to the aggregator, and the aggregator determines the median price, which is then used as a reference price on the platform.
Compound is a money market protocol that allows users to earn interest and/or borrow assets with collateral as collateral. Similar to MakerDAO, Compound also uses an oracle to collect price information, and then forward this information to its price feed, which is managed and controlled by the “administrator” of the holder of Compound’s native token COMP.
Lightning loans and the need for tamper-proof oracles
Like the concept of liquidity mining, a new liquidity mechanism has emerged in Decentralized Finance (DeFi). This is the so-called “flash loan”. Flash loans allow users to borrow assets from the on-chain liquidity pool without pre-collateralization, as long as the borrowed liquidity plus a small fee is returned to the liquidity pool in the same transaction.
This innovative design increases all users’ access to capital in various use cases, while ensuring the full and continuous solvency of the underlying liquidity pool.
In a short period of time (the span of a transaction), flash loans can enable anyone to become a fully capitalized participant, providing hundreds of millions of dollars in liquidity.
This creates unique opportunities for arbitrage, collateral exchange, and the creation of leveraged positions, but it also brings certain risks, especially for a nascent ecosystem with protocols with varying degrees of decentralization and security. Smart contract developers should understand these risks in order to build more powerful applications for users.
Lightning loans and price oracle attacks
Agreements to obtain prices from a single source can easily be exploited by malicious actors with large amounts of funds, who can manipulate the market through a large transaction.
Since flash loans can provide instant and considerable liquidity to anyone in the world at any time, they are increasingly being used to fund attacks on the DeFi protocol. However, there is a key difference here: Lightning loans only provide funds to execute attacks-the real problem is that there is no centralized price oracle that provides sufficient market coverage.
Posted by:CoinYuppie，Reprinted with attribution to:https://coinyuppie.com/oracles-the-invisible-pillar-of-defi-and-blockchain-applications/
Coinyuppie is an open information publishing platform, all information provided is not related to the views and positions of coinyuppie, and does not constitute any investment and financial advice. Users are expected to carefully screen and prevent risks.