Smart contracts are an exciting innovation in the blockchain space that enables the automated and trustless execution of complex agreements between parties. However, smart contracts are limited by their inability to access off-chain data, which can have a significant impact on the outcome of the contract. That’s where Chainlink’s Data Feeds come in.
Chainlink Data Feeds provide secure and reliable access to real-world data sources that smart contracts need to function correctly. This allows smart contracts to access off-chain data, such as market prices, weather conditions, or other external events that can impact the contract’s outcome. By integrating Chainlink’s Data Feeds, smart contracts can execute more complex use cases and unlock new possibilities that were previously impossible.
In this blog, we will take a closer look at Chainlink’s approach to collecting data from off-chain sources, the role of consensus in ensuring data accuracy, and how this data is provided to smart contracts. We’ll explore how Chainlink’s Data Feeds are helping to unlock new possibilities in decentralized applications.
Related Article
What are Oracles? & How is Chainlink Leading to Provide Optimal Solutions?
CHAINLINK ARCHITECTURE
Chainlink uses two architectural models such as the Off-Chain Reporting and Decentralized Data Model, to retrieve data from off-chain sources and transfer it to smart contracts.
Off-Chain Reporting
Chainlink leverages Off-Chain Reporting (OCR) to ensure decentralized data collection from off-chain sources. OCR involves multiple node operators who are responsible for providing data for specific data feeds. Protocol execution occurs predominantly off-chain over a peer-to-peer network between Chainlink nodes. The nodes periodically elect a new leader node, which drives the remainder of the protocol. During communication, a lightweight consensus algorithm runs in which each node reports its data observation and signs it.
The leader node routinely requests followers to provide freshly signed observations, which it aggregates into a report. It then sends this report back to the followers and asks them to verify its validity. If a required number of followers approve the report by sending a signed copy back to the leader, the leader assembles a final report with the quorum’s signatures.
Subsequently, the leader node submits a transaction with the aggregated report to the on-chain aggregator. Each report comprises many nodes’ observations and must be signed by a quorum of nodes.
All nodes monitor the blockchain for the final report to eliminate any single point of failure during transmission. If the designated node fails to confirm its transmission within a specified period, a round-robin protocol takes effect so that other nodes can also transmit the final report until one of them is confirmed.
Submitting only one transaction per round delivers numerous advantages, including reduced network congestion from Chainlink oracle networks, lower gas costs for individual node operators, improved scalability for node networks, and more timely updates for data feeds, as each round no longer needs to wait for multiple transactions to confirm before a price is confirmed on-chain.
Decentralized Data Model
The decentralized Oracle network contains three components:
- An Aggregator Contract
- A Proxy Contract
- A Consumer Contract
An Aggregator Contract
After the report is conveyed to the on-chain aggregator, it undergoes a verification process wherein the aggregator confirms that a requisite number of nodes have signed the report and also checks the validity of these signatures. Subsequently, the aggregator publishes the median value to the consumer contracts along with a block timestamp and a round ID.
Aggregators are updated by the oracle network only if one of two threshold conditions is met:
Deviation Threshold: A new aggregation round is initiated by the nodes when the off-chain value of a price feed deviates from the on-chain value by an amount greater than the defined deviation threshold (each price feed has a different deviation threshold value which you can see at data.chain.link). This ensures that the updated values of the price feed are accurately reflected on-chain. For example, in the case of ETH/USD if the off-chain price deviates from 0.5 % then the new data aggregation round starts and repeats the same process.
Heartbeat Threshold: In addition to the deviation threshold, a new data aggregation round is also initiated when the heartbeat threshold is reached, even if the price deviation remains within the deviation threshold. The heartbeat threshold is the specified time interval between two consecutive data updates.
A Consumer Contract
The consumers are our smart contracts which inherit the aggregator interface (for example AggregatorV3Interface
) and calls one of the exposed functions of the data to feed the aggregator.
A Proxy Contract
Proxy contracts are on-chain proxies that point to the aggregator for a particular data feed. Using proxies enables the underlying aggregator to be upgraded without any service interruption to consuming contracts.
Conclusion
In conclusion, Chainlink provides a decentralized infrastructure that enables smart contracts to securely access off-chain data sources. This is achieved through a network of independent node operators that retrieve and verify data from various sources. By using a decentralized approach, Chainlink eliminates the single point of failure and ensures the reliability and accuracy of the data. This allows smart contracts to be executed with confidence, unlocking a wide range of new use cases and applications for blockchain technology.
This comprehensive guide aims to provide assistance to developers of all skill levels and is intended to be beneficial for a wide range of developers. The information provided is intended to be easily understandable and actionable for all readers.
If you found this content helpful, please consider giving it a clap and leaving any feedback for future improvements. Your suggestions and comments are greatly appreciated and will help make these articles even more valuable for you and other readers.
Be sure to follow me to receive updates on my future articles and stay informed of new content.
Thank you
Top comments (0)