Have you ever opened up an encyclopedia? It’s been a while since I’ve actually been to a library, but last time I did, the encyclopedia had like 20 different separate books, but when I opened a page I immediately found a ton of information on whatever that page was about. The internet is kinda like a big encyclopedia, except we would need a library the size of Texas to hold all that information. If you’re here, you probably are wondering how that’s relevant to a blockchain oracle, and we’ll get to that, but first watch this video if you’re new:
Blockchains are simply technology that store data, usually transactions, into a group called a block. Each block has some data before it, and some data after it, but all they do is pretty much store transactions.
Next up, advanced blockchains can have something called smart contracts. We actually have an entire video explaining what a smart contract is, and going over some examples of them, so check that video out first if you haven’t already. As a recap, smart contracts are agreements on the blockchain that only get executed if the agreements are met.
For example, we could say “If WhiteboardCrypto doesn’t have 1,000,000 subscribers by 2022, pay Theodore $100”. We could also write a smart contract to allow us to swap coins and tokens, for example “If John gives us 10 zTokens, then give him 4 yTokens.” Even more advanced smart contracts will allow us to write insurance contracts, where you pay a monthly premium, and then if something happens like your house burns down, that insurance contract can pay you for it.
You can see how complex these smart contract agreements can get, but you may be asking one big question: “How does the blockchain know if my house burned down?”.
What do Oracles do?
An oracle is a trusted third-party that gives you reliable data outside your current information access. Back in medieval times, an oracle was a person who could use their crystal ball to see into the future, essentially giving reliable information to someone who wanted it. Whether you believe in that stuff or not, when it comes to blockchains, they want the same thing.
See, a blockchain can’t see outside of it’s own code, it can’t go searching around the internet, and it can’t even ask for information. It’s simply coded to store data and transactions. However, we can write smart contracts in a way that they rely on third-party information like the price of a stock, the outside temperature, or who won the presidential election. The Oracle can act as a middleman between the blockchain and the real world. Also, Oracles aren’t real things, they’re usually just code programmed by someone and trusted by a lot of people. So there is no real physical oracle out there, it’s kinda like the internet, we all can use it, but it’s not really one thing.
Let’s go through an example of each thing that I mentioned.
You could create a new token that follows the price of a stock. This way, investors outside of the United States could invest in stocks without needing to have a Social Security Number or report their taxes or many of the other hassles that come with investing in stocks. You can use an oracle to create a synthetic token that tracks it’s price to the real world price of a stock.
There are obviously a few other issues you have to solve with this, as it’s very complicated, but the Mirror protocol has done exactly that. You can buy mGoogle and hold it just as you would the real Google stock, and the price of the mGoog token is tracked to the real world Google stock price through Chainlink.
Secondly, I mentioned farming temperatures. This is kinda a fun one to explain. Imagine you’re a farmer and you want some crop insurance. This way if something crazy happens like a 10 day drought happens or it rains for a year, you are protected. The way insurance works, is you pay a monthly premium that goes into a large pool of money.
That money is stored with other people paying their premiums, and using statistics, we can reasonabily predict that the amount we require people to pay will cover their issues. So if one year your crops don’t grow because it’s too hot, you can have a $100,000 payout from the insurance smart contract. An oracle would be needed here, because how does the blockchain know if there’s a drought?
Well, you can feed it the temperature of your location, and if it looks at the temperature and it’s more than 100 degrees fahrenheit for 10 days, we can say that you should be paid. Of course, this is just an example and how insurance works is far more complicated than this, I just wanted to show another example of how we can use oracles and smart contracts to basically recreate the traditional way of insurance using a decentralized, trustless, and probably more affordable method using blockchain technology.
Who won the presidential election?
Have you seen that website where you can practically gamble on who wins certain elections? I definitely have, and it’s an interesting idea, although it could definitely be implemented with blockchain technology and using cryptocurrencies. Instead of paying with a credit card, then voting, and waiting for the poll to happen and trusting the platform to reward you if you won, we could write all of this with code and host it right on Ethereum. This way we paid with ethereum or USDC, waited to see who won, and then let our trusted decentralized oracle do the work of paying out the winners. Speaking of decentralized oracles, one of the benefits is that we don’t have to trust one data source, right?
Blockchains are decentralized, meaning no one person or company can control them. Oracles should be too, meaning you don’t get data from one source, because if you did….you have one point of failure and your data is technically centralized. So, how do we make an oracle decentralized?
Chainlink seems to be the answer, and I don’t want to go too deep into it with this video, but they have an entire blockchain that is focused around supplying reliable real-world data from temperatures to prices to even the number of views on this video. We actually have a video for Chainlink scheduled, so if you’re not already subscribed, go right ahead… it lets you know when we upload new videos and it rewards our hard work!
There are other types of oracles, but they usually specialize in one of three categories. Hardware oracles read information from real-world sensors, like a temperature, or a weighing scale, or if an NFC tag can be found nearby. Software oracles find information on the web, like stock market data or how many users are on a website. Human oracles are oracle that consolidate human data, like reviews or important ideas from people with specialized skills or knowledge, but that starts to get very complicated.
Thanks for watching, we hope you enjoyed this video, we really hope you learned something, and most of all, we hope to see you in our next video!