A smart contract in the blockchain world is a digital agreement (a program) that enforces itself. As Vitalik puts it. “ the program runs this code and at some point it automatically validates a condition and it automatically determines whether the asset should go to one person or back to the other person, or whether it should be immediately refunded to the person who sent it or some combination thereof.”
A smart contract has the advantage that it does no need to rely on other parties. There are no judge, no juries , no mediators. It is entirely self contained.
In principle this concept is very powerful but adoption of smart contracts is very difficult when mapped to the real world.What if the smart contract needs to rely on aspects related to the past or the future or things that are ambiguous. To be useful smart contracts needs a reliable way to connect to the real world and access a data source.
We need a travel insurance smart contract to be able to determine when a flight has been delayed so it need access to a trustworthy source of real time flight data. We need a car insurance smart contract to be able to determine that a car has been totalled, access to exchange rates, weather information, gps information and so on.
Smart contracts in the real world are only usable if an oracle is provided. This oracle is accessed by the contract to provide access to real world events. This poses what is known as the oracle problem were we have a decentralised environment that needs to access a source of data which end up being a central point of failure. How can we be sure that the oracle is providing the correct information what if the oracle is compromised.
The major innovation from in this field is currently being spearheaded by a company called Chainlink. Chainlink is described as a decentralized oracle service, providing a connection between blockchain to an off-chain data source. Their aim is to give the smart contracts on the blockchain access to data feeds and APIs.
The chainlink implements the oracle infrastructure using three contracts that run on the blockchain.
- A reputation contract that keeps track of the oracle service provider performance.
- An ordering matching contract that selects the offchain oracles and executes the agreement and the deliver the requested data,
- A aggregation contract that collects all the data delivered by the offchain oracles and averages it out, creating a weighted aggregate answer.
The on-chain workflow is composed of the following three actions.
- Oracle Section. The user submits his set of requirements including the level of reputation of the oracle and number of oracles needed. This information is composed as SLA (Service Level Agreement). Users can select the oracles manually or else use an automated bidding system were oracles bid on the requested contract.
- Data reporting. The chosen oracles execute the service level agreement and report back the information on the chain.
- Result Aggregation. The aggregation contract collects the data from all the oracles and averages out the result to provide an accurate answer.
Off-chain oracle operators are compensated with tokens for the information provided. Oracles are also penalised if they misbehave. The use of multiple oracle allows Chainlink to implement a decentralised oracle infrastructure with no single point of failure thus allowing smart contracts to be use information from outside the blockchain.
White paper of the Chainlink project can be accessed from the following link.
Hope you liked this article. Feel free to add me on Linkedin here or contact me on email on [email protected].