Hello subs, happy Thursday! Thank you to the 4 new subscribers who have joined Cryptalks on the journey of learning about the future. Our community now stands strong at 52 members. It took Cryptalks 3 months to go from 0 to 50+ subs and it wouldn’t have been possible without you fine people so thank you guys for showing your support and reading these posts every week!
It’s been 2 weeks since I posted this ‘weekly’ newsletter and I had some of y’all call and ask me why I hadn’t posted. If I’m being honest with y’all, I bit more off than I could chew with regards to work which caused a burnout and lack of motivation to do anything outside of it. The good news is that I’ve learnt from my mistakes, got my friend to create a basic logo for the newsletter, started creating a structure for each post (the structure will always be a work in progress) AND I gained more subs so I guess this is….
In today’s post we’re going to talk about Oracles. This post is a little jargon heavy so I’d recommend you read this one slowly.
If you remember, I’d mentioned oracles in the post that spoke about Decentralised Finance. For those who don’t, an oracle is a source of real-world-data that a Smart contract needs to unlock it’s full potential. It helps in providing the correct values of off-chain-data and put it on-chain. Why do we need them? Because without a reliable connection to real-world-data, we cannot effectively solve for real-world-problems. Let’s understand oracles with an example.
Imagine an on-chain protocol that allows users to buy and sell shares listed on any stock exchange around the world using ETH. A smart contract is created to . This smart contract needs to know the price of all the shares at any given point in time so it needs to get this data from the outside world onto the blockchain. If this was a web2 company, the best step would be to call an API that provides this data but with web3 it’s a little different. For all my non-tech bros wondering what an API is - Application Programming Interface is a piece of code that helps two different softwares communicate and exchange data with each other. Now coming to why APIs cannot be used in the new realm:
Blockchains work on a consensus mechanism where each node has to validate a transaction to create a block. Reaching consensus on transactional data is easy. If I have 52 ETH in my wallet and I send it to each of my subscribers, each node can easily reproduce this transaction of subtracting 52 ETH from my wallet and adding 1 ETH each to your wallets. The data is constant. Now let’s say I want to share the price of a share of Tesla instead of transferring funds. The node calls an API and sends the price to y’all. When every other node on the blockchain goes to validate this transaction, they will call the same API again but the price they get even after a second is going to differ from the price the other nodes got. This would lead to no consensus, the business shutting down and my on-chain reputation getting REKT.
Oracles would stop my imaginary business from failing. Unlike API calls, oracles do not feed the data to the blockchain directly. Instead they collect and store the data from the real world. When the smart contract concerning this off-chain data is executed, the code calls for the right information from this trusted oracle instead of each node calling the API. This data is then processed as a transaction on chain, therefore leading to consensus amongst all nodes.
Like everything else on the blockchain, Oracles are a work in progress too. There was a big problem with oracles. It’s referred to as ‘The Oracle problem’. To understand that let’s rewind to why we’re building the 3rd iteration of the internet in the first place. The biggest reason that smart contracts, blockchains etc. are being created is decentrality. Pulling data from a centralised or single API would essentially remove one of the biggest benefits we have. It means that one single source of data would have control over the entire execution of the smart contract, essentially making it a regular contract.
So what’s the solution? Every on-chain problem deserves an on-chain solution and that is exactly what protocols like Chainlink do! They solve the oracle problem by creating a decentralised network of oracles. Each oracle is a node just like on any other blockchain. Each of these nodes have an on-chain address and functions that enable smart contracts to read from that address.
Take the above image as an example. The oracles on the right are nodes that provide the price for ETH/USD. For the data feed to get updated, the smart contract would require a response from a minimum number of oracles otherwise the price would not be updated. The minimum number for this feed can be seen in the ‘Oracle responses’ container which is 21 out of 31 total nodes present in this network. Once the oracles publish the data, it is validated and aggregated by a smart contract which forms the feed’s latest and trusted answer. This particular network, updates the ETH/USD price every hour. These nodes/oracles gets rewarded for publishing this data. You can check the different data feeds on chainlink here.
So to sum it up, oracles are basically blockchain middleware as they bridge the blockchain world to the real world. But in order to maintain the decentrality and security of blockchains, oracles need to be decentralised as well. This is made possible by forming a network of oracles that aggregate and validate the incoming data. A handful of protocols like API3, Band protocol and DIA solving for this issue commonly known as ‘the oracle problem’.
I’ve tried to keep this one as easy to understand as possible but if you are someone who wants to deep-dive into this topic, you can check a more detailed article here.
Don’t forget to drop a like if y’all learnt something valuable today and tell me what you’d like to see more of, I read all your comments. It takes less than a minute and it helps the substack algorithm to show this newsletter to more people! It also low-key (high-key) makes me feel good when y’all show some love. 😜
DISCLAIMER: This post is NFA. DYOR!
I’m going to play the role of a plug for my dear friend Rohit who took the time out to create a logo (still a WIP) on extremely short notice. He’s also a solidity dev and a part of Developer DAO so please show him some love on twitter and pick his brains on his journey of becoming a web3 dev in around 4 months!