Oracles are blockchain structures that bring off-chain data to be used in smart contracts. Blockchains are generally closed systems and therefore cannot be aware of information outside of their ecosystem. Oracles enter the scene exactly at this point, taking data sources outside the blockchain (off-chain) and processing this information on the blockchain (on-chain).
But why? 😮
This is exactly the question that should follow. Why do smart contract and, naturally, smart contract developers need off-chain data? Let's try to clarify the situation with a current example.
Currently, the World Cup organization, which is watched by millions of people around the world and held in winter for the first time, is ongoing. Let's say you want to develop a dApp based on the question of who will be the top scorer in the World Cup. Since the information about how many goals each player scored in the World Cup is not available on the blockchain, we need to somehow find out how many goals each player has scored in total until the end of the final match and divide the total liquidity of the users participating in this bet equally among the winners according to the result. Oracles enter the scene exactly at this point, both providing and confirming this information.
Let's delve a little deeper into the relationship between Smart Contracts and Oracles 🤿
As mentioned above, Oracles "pull" off-chain stored information for smart contracts working on the blockchain, as well as verify and transfer this information. In addition, Oracles can "push" on-chain data, allowing off-chain systems to access data on the blockchain. In a single word, we can say that Oracle applications act as a bridge between smart contracts on the blockchain and off-chain data providers.
Blockchains are closed systems and therefore cannot communicate with the real world on their own. This may initially sound bad, but it is thanks to this closed nature that blockchains can operate as deterministic systems. To briefly define deterministic systems, they are systems that always produce the same output regardless of initial conditions/situations and particular input. In other words, there is no randomness or variation within them. In order to be deterministic, blockchains limit their nodes and only ask simple binary (true/false) questions in consensus and seek answers to these questions. For example:
Does the account have sufficient balance to cover the transaction made on the blockchain?
Is the transaction approved by the smart contract?
Let's consider and examine a structure in which blockchains are not closed to the outside world and further reinforce the importance of their deterministic nature. If blockchains were open systems, it would be possible to receive different outputs from each node, and the deterministic structure could be disrupted. Let's say we consider a trade on the ETH-USD pair and assume that we pull it through a traditional API. In addition to causing constant fluctuations in the price, as often happens in real life, if the API is removed or hacked, it would be possible to receive different outputs from the same smart contract executed on the nodes, which would obstruct the deterministic structure from producing the same output regardless of the initial conditions or specific inputs. In this case, we might have made the trade on the ETH-USD pair much cheaper or much more expensive at the time, and we could have presented a huge security vulnerability, which is essential to blockchains.
The Oracle Problem ⚠️
We have looked at the relationship between smart contracts and oracles, and we have seen what kind of problem we would face if blockchains were open systems. Now it is time to take a few steps back and look at a wider perspective. Why do we write smart contracts on-chain? Why should Oracles be decentralized?
If we pulled the data from a single API, node, or source, we would strike the first blow to the reason for the existence of the blockchain, decentralization. A central Oracle means that a community has complete control over a smart contract. In other words, it can be said that the written smart contract is not much different from code written in the real world. More importantly, like any centralized system, central Oracles are also vulnerable to hacking and attack, and they may lose their timeliness, which is enough to drag the system into disaster. Once faulty data is reported to the blockchain, it becomes part of the immutable structure. If the smart contract is executed incorrectly due to this data, the written smart contract not only fails to do what it is supposed to do but also causes irreversible damage. In short, Oracles should not rely on a central structure when bringing data on-chain, or the decentralization of smart contracts will be lost.
The Solution: Chainlink & Decentralized Oracle Concepts🥳
To solve the Oracle problem, it is sufficient to find solutions to these two simple points:
Blockchains cannot access external data on their own.
The use of centralized oracles removes the advantage of using smart contracts and also brings large security issues.
Chainlink has solved and standardized decentralized oracle structures by finding solutions to these two questions. A decentralized oracle or decentralized oracle network is essentially a group of independent blockchain oracles that are responsible for providing data to the blockchain. Each independent oracle fetches data from an off-chain source and brings it on-chain. The collected data is then aggregated, allowing the system to remain deterministic for this data. In this way, decentralized Oracles solve the Oracle problem.
Chainlink connects smart contracts with real-world data using decentralized nodes, allowing smart contracts to reach their full potential. This allows the use of the same reliable, decentralized infrastructure concept for blockchain Oracles. If a node or source is hacked, deleted, or becomes outdated, Chainlink compensates for this and the decentralized network continues to operate. While running a single Oracle is risky, Chainlink provides a superb Oracle ecosystem for data usage. In addition, Oracles also support interoperability, or the ability for two different blockchains to recognize each other. Ultimately, we need variety and reliable data, and therefore Oracles, for smart contracts to operate at their best.
Conclusion
In conclusion, blockchain oracles are an essential component of the blockchain ecosystem, providing a link between smart contracts and the outside world. Decentralized oracles, in particular, are important because they provide a trustless and secure way to connect smart contracts with external data. Chainlink is a leading provider of decentralized oracle services, using a network of nodes to validate and verify external data before it is used in smart contracts. The relationship between blockchain oracles and smart contracts is a close one, with oracles providing the essential link between the decentralized world of blockchain and the outside world of data and events.