What are oracles in blockchain?
![What are oracles in blockchain?](https://wsrv.nl/?url=https%3A%2F%2Fcodedamn-blog.s3.amazonaws.com%2Fwp-content%2Fuploads%2F2022%2F10%2F20120417%2FOracles.png&w=1280&q=82&output=webp)
If you are developing decentralized applications or learning blockchain development there are high chances you have heard the term oracles somewhere. In this article, we will take a close look at what are oracles and why we need them.
What are oracles?
Oracles are nothing but external services that feed data onto the blockchain. Blockchain can not see outside of its code as they only deal with the data within the network. It can’t look outside for querying something on the internet as blockchain is built to store data and transactions securely in a decentralized way within a network itself.
And that’s where oracles play a significant role. Oracles enable the interaction between the blockchain and the outside world to interchange the data for utilizing the smart contracts and blockchain to their utmost capabilities and build an awesome decentralized application for better use cases and solve existing problems in a centralized world.
Oracles act as APIs that provide off-chain data (real-world information) to the blockchain. Oracles are also known as blockchain middleware as they connect the outside world to the blockchain.
Oracles are not data sources by themselves, they do collect, query, collect, verify and authenticate the off-chain data from different sources
and then feed it to the smart contracts as a single final result. The data oracles feeding to the blockchain can be stock prices, weather conditions, data collected from IoT devices, the result of the sports game, etc.
There are different implementations of oracles, oracle platforms might be using different techniques to provide you with these data but remember the only goal of oracles is to deliver the off-chain data to the blockchain for a certain purpose.
Why do we need Oracles?
To Understand why we need oracles, let’s take an example.
Let’s say you are building a decentralized application using a smart contract for a betting application based on a car racing game happening in the real world.
Now there is no way a smart contract has information about the result data of the racing game because the smart contract has access to only onchain data that is available on the blockchain where the smart contract is deployed.
So without having the result data of the race, a smart contract can not make a decision on its own to announce the winner and if you provide any wrong information to the smart contract on your own then the wrong user will get paid and there is no way to revert that transaction as blockchain is immutable by nature.
And this is where oracles show up as a solution. Oracles gather the result information of the race from different sources and will deliver it to the smart contract after verifying and authenticating it.
All in one, we need some trusted source for pulling the off-chain data to the blockchain, and that’s where we need oracles.
Types of Oracles
Based on the flow of information between oracles and their sources oracles can be categorized into two types :
Inbound Oracles
Inbound Oracles deliver the off-chain data to the blockchain.
Outbound Oracles
Outbound Oracles bring or send blockchain data to the outside world.
Based on where oracles withdraw their data from, oracles can be categorized as :
Software Oracles
Software oracles receive and deliver data from internet-based services such as servers, databases, websites, etc.
Hardware Oracles
Hardware Oracles receive data from information-reading devices such as sensors, cameras, barcode scanners, etc.
The oracle problem
The oracle problem exists in centralized oracles. As we discussed centralized oracles are controlled by a single entity which means a single point of failure.
The smart contracts implement the code logic or the conditions based on the data provided by the oracles.
So if oracles that are controlled by a single entity get compromised, the smart contract will also be compromised as it relies on a single source for the data and has control over the entire execution of the smart contract. And if there is a single point of failure which gets triggered the whole system would stop working. And that’s what the Oracle problem is.
The main reason we are moving to blockchain technology is that it provides decentralization. So if we are pulling data on a decentralized system using a centralized entity we are getting rid of the main reason why we are using blockchain in the first place. And that’s why the protocols like chainlink and makerDao are building a decentralized oracle platform to avoid the oracle problem and deliver a more secure and efficient solution.
Conclusion
Oracles open the door for communication between the blockchain and the outside world. These kinds of solutions are pivotal for the adoption of blockchains, as they unlock the blockchains to their true potential and let us build a decentralized world. Otherwise, the use cases of blockchain would be limited as they deal with the data only within a network (onchain).
I hope you all understood the concept of oracles in blockchain and enjoyed reading the article.
Sharing is caring
Did you like what Shashank Wangkar wrote? Thank them for their work by sharing it on social media.
No comments so far
Curious about this topic? Continue your journey with these coding courses: