What is ChainLink?
Updated: Aug 12, 2020
To understand Chainlink, one needs to first understand Smart Contracts
A smart contract is an agreement with an “if/then framework” that runs on a blockchain. They execute automatically when certain conditions, as defined in the agreement, are met. No central authority oversees the transactions which are tamperproof.
Examples of smart contracts include:
Crowdfunding Smart Contract - Transfer money to the account of the fundraiser only if certain minimum funds are raised. If the minimum is not raised by a certain date then the money raised is returned to the contributors.
Insurance Smart Contract - Automatically release funds to the insured when say hospitalization records are submitted or rainfall is above a certain level as reported by an authorized observatory.
Supply Chain Smart Contract- Make payment to the supplier when goods reach the warehouse of the buyer as confirmed by QR code reader at the warehouse and make payment to the logistics provider if thermostat readings confirm that ideal temperatures were maintained during transportation.
One might notice that the above smart contracts require data that has to be procured off-chain (hospital records, weather reports, QR code readings, thermostat readings, etc). Blockchains however do not support communication with external systems. This is where Oracles come in. An Oracle is an off-chain data feed that provides connectivity to the outside world.
However, relying on centralized Oracles kind of defeats the purpose of blockchain. That would represent a potential central point of failure. Malicious parties could control it making it untrustworthy. Since smart contracts are immutable, incorrect action taken on the basis of incorrect data will also be immutable. Hence oracle security is a high priority.
This is where Chainlink comes in. Chainlink is a decentralized Oracle network that enables communication between off-chain data and on-chain smart contracts. It tackles the risk of relying on a single centralized data source. It does so by following the following 3 contracts:
* Reputation contracts- When a smart contract sends a request for data specifying details like query parameters and a number of oracles needed, Chainlink verifies the identities and considers the reputation of the available oracle nodes. It looks at logs of past contracts and removes any nodes it finds unreliable.
* Order-matching contract- The nodes that clear this check are invited to send bids on the request. Bidding involves committing a stake of LINK tokens which can be confiscated in case of malicious behaviour or poor service. Greater stake increases the likelihood of getting selected to fulfill requests. This step is important otherwise multiple freeloader nodes might simply send data by copying the data sent by other oracles.
* Aggregating contract- Finally all the data from the selected oracles is collated. If the data comes from the same source like weather data from the HK Observatory and 4oracles have 1 answer but 1 oracle has a different answer then that different answer and oracle are discarded. If the data is coming from multiple sources then Chainlink may need to take an average.
Chainlink also functions as a translator between the smart contract and oracles by translating between on-chain and off-chain programming languages. The request is translated from on-chain to off-chain language for the oracles to understand and the collected and validated data is translated from off-chain to on-chain language for the smart contract to understand.
Oracles are paid in LINK tokens for their service. Prices are set based on demand.