Blockchain has seen an immense rise in popularity since the creation of the Bitcoin blockchain in 2010. Blockchain has proven it has a use, providing key properties like decentralization and security.
However, a blockchain is a closed ecosystem, which obviously improves security and offers data integrity. Later, smart contract technology provided developers with programmable contracts that could be executed on the blockchain. The outcomes of each contract are stored “on-chain.” Unfortunately, blockchains being a closed ecosystem limited the true potential of smart contract technology.
Assume you want to create a smart contract that allows people to gamble on today’s average temperature. We can code all the gambling logic, but how do we access the temperature data? Because blockchains are a closed ecosystem, we can’t call an API to access temperature data from inside the ecosystem.
In this situation, some might answer that you call any publicly available API that can provide you with temperature data. Well, this solution might look very straightforward, but it’s not as straightforward as you might think.
This article discusses the following topics:
There are several inherent problems with public APIs that can spoil the results of our gambling smart contract. Here are the most critical problems:
First of all, we need to program our smart contract so it can handle API failure. What should the contract do if the API doesn’t respond? The most obvious solution here is to return the tokens to the participants.
Next, what should we do when the API sends invalid data? For instance, the temperature API returns 100 degrees Celsius (212F) instead of 10 degrees Celsius (50F). As the contract received a response from the API, it will pick a winner based on the received data even though it is incorrect. We can’t simply undo smart contract actions. Therefore, data reliability is a big issue for smart contracts to handle.
Furthermore, we need to consider API manipulation. Imagine that one of the gambling participants contacts the temperature API’s owner and proposes to manipulate the response. For instance, the gambler submits 18.1 degrees Celsius as an answer. Then he asks the API owner to respond with precisely this number when the smart contract is executed to pick a winner. In return, the gambler agrees to share half of the prize money with the API owner.
It’s a very easy scam to pull off because only a single entity provides the data. As you can see, the solution of relying on a single entity opens up the path for manipulation. In other words, data centralization is the problem here.
And lastly, the most important problem with using a single API to retrieve temperature data is determinism. It’s easy to understand why this is the biggest issue when calling a random external API.
To put it simply, all operations on the blockchain should be deterministic. This requirement means that the same operation performed across different nodes should return the same result. For instance, one node calls our API a few milliseconds later. The slight delay can even return different data. Perhaps the forecast changed slightly from 18.1 degrees Celsius to 18.2, which results in a different winner. As you can see, we get different results, which means the nodes can not agree on a single result. Therefore, a single API isn’t reliable to deliver deterministic data.
For all nodes to agree on the same result (from smart contract execution), we need a source that can provide the smart contracts with deterministic data. In the previous section, we’ve learned that a single API brings many problems and can’t provide smart contracts with deterministic data. So, how does Chainlink solve this problem?
Chainlink has developed the concept of oracles. A blockchain oracle is an external service that provides smart contracts with external information. They act as a bridge between the internal blockchain ecosystem and outside data. Obviously, they provide deterministic data. But how do they do this?
As Patrick Collins explains, “A decentralized oracle or decentralized oracle network is a group of independent blockchain oracles that provide data to a blockchain. Every independent node or oracle in the decentralized oracle network independently retrieves data from an off-chain source and brings it on-chain. The data is then aggregated so the system can come to a deterministic value of truth for that data point.”
In short, decentralized oracles help us improve the reliability of the information provided to smart contracts by not relying on a single source of truth. They allow anyone to verify the data provided to the smart contract. As you could have guessed, Chainlink offers this service.
If we get back to our temperature example, let’s assume we use a temperature oracle. This decentralized oracle consists of five oracles that fetch temperature data from different sources. We get the following results:
When aggregating the above data, we get an average temperature of 18.16 degrees Celsius, which gets recorded to the blockchain via a transaction. Now, our smart contract can access this data on-chain, which is deterministic and verifiable.
You might wonder if Chainlink’s decentralized oracles can fail. The answer is yes; things can go wrong. In February 2020, DeFi users were able to make ~$36.000 worth of profits due to an error with Chainlink’s silver-to-USD oracles. For a short period of time, the XAG-USD oracle reported a price of approximately $1,600 for an ounce of silver, while the actual market rate should’ve been $18. So, how did this 200-fold price increase occur if we consider our knowledge about price aggregation?
Well, a human error caused all the trouble. The XAG-USD pricing oracle relies on nine independent node operators to provide pricing data. In this situation, one of the node operators tried to improve the gold-to-USD (XAU-USD) oracle and accidentally misconfigured the XAG-USD oracle. Instead of returning the silver price, one of the oracles returned the gold price. As the difference between the gold and silver price is so large, the average price ended up being 200 times bigger than the actual silver price.
What can we learn from this? The concept of decentralized oracles certainly works in 99.9% of the cases. Yet, we have to remember that these nodes are maintained by humans, who are a weak link. The pricing anomaly incident was a one-time accident and can be resolved by adding additional security checks for pricing data. For instance, exclude nodes who report data that deviates strongly from the average reported data by other nodes. It shows that oracle technology has a substantial learning curve ahead to offer 100% reliable off-chain data to smart contracts.
At the moment, there are two competitors worth mentioning: Band Protocol and Tellor. Let’s look at how they compare to Chainlink.
Band Protocol offers the same service as Chainlink: Connecting smart contracts with trusted off-chain data provided by community-managed data providers.
Band Protocol uses their BAND token as collateral. Any BAND token holder can become a data provider by employing a data source contract. They can then register themselves as a candidate data provider by using the BAND token as collateral.
Each time a smart contract accesses data from Band Protocol’s data providers, they have to pay a small fee. This fee is distributed across the data providers. On top of that, the community can vote for certain data providers, so you end up with a ranking of data providers. This ranking ensures that more trustworthy data providers are picked for providing data to smart contracts.
On top of that, the ranking system drives competition, and therefore, drives the quality of the data.
Tellor takes a different approach to decentralized oracles. The Tellor team has created an on-chain database, which is called Oracle. Miners can compete to add data to the database. The data is then consumed by smart contracts that rely on off-chain data.
To make sure that miners supply the correct information, they use a social law system. Whenever someone suspects a miner of providing false information, they can open a ticket. The community can then vote on this ticket to determine if the information is correct or not.
The day after the vote, the condemned can challenge the result. However, the condemned has to pay a high fee to challenge this result. This high fee is designed to discourage users from challenging the results from the voting all the time. If the miner loses the case, they lose the fee as well. If it turns out that the miner has provided the correct information, they will receive an additional reward.
In conclusion, Tellor’s Oracle database is quite different from Chainlink and Band Protocol’s approach.
So, let’s take a fundamental look at Chainlink’s price. We’ve listed a couple of arguments that favor Chainlink.
To get a more nuanced view, let’s take a look at a big issue, which is pricing:
In short, Chainlink is still one of the best providers within the decentralized oracle industry, yet it is unsure if this is the best solution for feeding off-chain data to smart contracts. We’re trying to say here that the system still shows weaknesses that can cause major problems for crypto projects that rely on Chainlink’s oracle services. We might see new projects come up with alternative approaches that provide a better mechanism to serve off-chain data.
If you want to learn more about which type of use cases are powered by Chainlink, here’s an article that describes 77 smart contract use cases.