Oracles: Connect real-world data with the Blockchain world

Oracles: Connect real-world data with the Blockchain world
Photo by Viva Luna Studios / Unsplash

What are oracles?
In the blockchain, any data that is written on-chain is accessible. However, we cannot access anything which is outside of the blockchain. To fill this gap oracle comes into play. Oracle is a middleware that is used to connect off-chain data to on-chain. In this way, smart contracts can get an input of real-world data and execute it in the blockchain. It acts as an API layer.

Architecture:
Chainlink architecture contains three parts. They are Chainlink Oracle Contract, Chainlink Node, and Adapters.

Chainlink Oracle Contract: Firstly, the node operator deploys the Oracle smart contract to the blockchain network, which accepts LINK tokens as payment via contract requests and dispatches events to Chainlink nodes.
Chainlink Node: The chainlink node serves as a bridge between the blockchain network and the real world. This will communicate with external data sources and fulfills the requests of the contracts.
Adapters: This is client-side software, that interacts with data sources
and will give the data back to the chainlink node.

How does it work?
At first, the smart contract will request data to the chainlink protocol and it will register it as an event, then it will create a Service Level Agreement(SLA) contract on the blockchain. This SLA contract will create three sub-contracts namely the Reputation contract, order-matching contract, and Aggregating contract. The Reputation contract will check the node’s track record for authenticity and performance history. Then it will remove the unreliable nodes.
The order-matching contract will transfer the request to the nodes and will receive the response, then it will pick the right nodes. The third contract named Aggregating contract will collect all the data from the chosen nodes and will validate it.

What are the Uses of Oracles?
Oracles are used in a variety of industries, including Decentralized Finance (Defi), Gaming, Insurance, and Non-Financial Transactions (NFT).
As an example, consider currency exchange. Let’s say We are developing a decentralized application in which users will be able to withdraw ETH worth a certain amount of USD. To fulfill this request, our smart contract must know the value of one Ether.
And here’s the thing: a JavaScript application can easily retrieve this type of data by making requests to the Binance public API. A smart contract, on the other hand, cannot directly access data from the outside world. In this scenario, we can use chainlink oracle. Chain link oracle has data feeds, that are reliable, inexpensive to use, and available across all nodes.

what are all the problems that can arise?
The main issue with Oracle is if it is a centralized oracle. Assume that all data from various entities are grouped into a single centralized entity, then there is no point in using blockchain. Blockchain is built with the idea of decentralization and data availability. Furthermore, if the centralized entity is unavailable, the smart contracts might not be unable to access the data. To solve this problem, decentralized oracles are available.

Decentralized oracles:
In decentralized oracles, each node will have a copy of all data. If any of the nodes fails, it will not cause a problem. There will be no centralized entity, and data from various entities will be stored across all nodes, ensuring that, there is no single point of failure.

Worried about attackers targeting your smart contracts? Contact us today to get your smart contracts audited for any security issues!


Yuvarajan

is working as a security engineer in Detasecure. He can able to perform memory forensics and can able to analyze malware. He has done B.E from Anna University. He is an active participant in capture the flag (CTF) competitions. You can reach out to him by Clicking Here.