Back to All Episodes
Season 1Episode 7

What is Chainlink?

February 11, 2022
38m
1 Guest

Listen Now

About This Episode

In this episode of DevNTell, Narb welcomes guest Richard Gottleber, a developer advocate at Chainlink Labs. Gottleber explains the power and benefits of smart contracts, specifically looking at how Chainlink can help overcome the 'oracle problem'. The episode focuses on how decentralization can offer transparency and truth to agreements and how Chainlink specifically offers data feeds, VRF and keepers to support this. Gottleber even walks listeners through a live demo on building a smart contract using data feeds.

Key Takeaways

1

Smart contracts and cryptographic truth are moving from trust-based to truth-based systems.

2

Decentralized oracle networks like Chainlink can bring off-chain data on-chain in a deterministic fashion.

3

A hybrid smart contract is a smart contract that takes both on-chain and off-chain data into account.

4

Price feeds are some of the most popular data feeds and are ready-to-use out of the box.

Featured Guest

RG

Richard Gottleber

Developer Advocate @ Chainlink Labs

Chainlink Labs

Timestamps(click to jump)

Episode Transcript

Narb

Gm gm gang. Welcome to what is going to be another great DevNTell. So if you didn't know, DevNTell is a thirty minute window for members of the DAO to showcase something they are passionate about or have been working on. This could be an awesome project you've been working on, demonstrating unit testing best practices, automation goodies, smart contracts, how to structure a project, and so on and so forth. Basically, if you've got a passion for something, this is your opportunity to share it with the community. And today I am happy to introduce Richard, who will be going over decentralized oracle networks for us, specifically Chainlink. Over to you Richard.

Richard Gottleber

Awesome. Thank you for the introduction. So yes, I am Richard Gottleber. I'm a developer advocate at Chainlink Labs. I guess just for the purposes of the DAO, like, I joined Developer DAO when it first started and it was really a jumping off point to getting to be a part of Chainlink Labs, which is awesome. The community here is really cool. So I guess I don't know if I should say thank you or not, but like, I'm glad to be a part of this community because it's really cool. My Twitter is there, my email is there, I am more than happy to chat anytime about anything, especially Web3 stuff because it's awesome, but other stuff too, whatever. I'm open to that. And yeah, let's dive in.

Richard Gottleber

I think probably everyone here is familiar with smart contracts in general, right? And the fact that they are providing a change in how we have agreements. At Chainlink we like to talk about the fact that we're moving from a trust-based system to a truth-based system. Historically agreements and contracts have worked based on trust, right? And if you were to make an agreement and things were to go wrong and the agreement didn't get followed through on, you're essentially relying on a third party, right? That kind of person in the middle who is going to be the arbiter of, does this contract hold or not? And a lot of times that's just fine, right? Like, I personally live in the United States and like the legal system here is pretty robust and like you can trust a legal binding contract to, you know, ensure that things happen the way they're supposed to. But I don't know, it's one of those things where it's always kind of bothered me, the 'most of the time things are fine'. That 'most of the time', even though here it's very rare for that to happen, is still a problem.

Richard Gottleber

And having this kind of like trust-based agreement system is problematic, right? You end up with things where in the past certain investment firms have decided, you know, that you can't trade anymore on a certain stock, and that's problematic. Enter smart contracts and cryptographic truth. Suddenly you have a truth or cryptographic-based system that ensures when an agreement is made it will execute the way that it says it will, right? You have essentially instead of relying on a third party, you're relying on the code and it's going to do what it says it's going to do. You also have a lot more transparency. This is like the power of smart contracts and like one of the things I really think is awesome looking towards the future is that you'll be able to have these agreements and know that things are going to work the way that they say they're going to work.

Richard Gottleber

That brings us to another factor when we talk about smart contracts and blockchains. One of the really powerful pieces of that technology is the fact that it is distributed, right? And or decentralized as well. And in order to have a network where you have various nodes that all are agreeing on certain things, it has to be what's called deterministic. So I don't know, I've we're a pretty small group. I'm going to ask you questions, if you want to just like chime in with answers that would be awesome. So talking about deterministic values, does anybody know what one plus one is?

Narb

Are we talking JavaScript or...

Richard Gottleber

Just...

Narb

Is it eleven?

Richard Gottleber

One plus one, right? Like integers, one and one, what is it? It's two, right? Like we can all agree, like jokes aside about JavaScript, but like that's a good point, but we can all agree that like you know if you add the integer one and the integer one, you're going to get two. It doesn't matter when you do this, it doesn't matter who does this, like that's the value, that's a deterministic value. That's really easy for a blockchain to come to consensus on, right? Because like every node can look at that value and say 'Sweet, one plus one is two, we agree.' That's awesome.

Richard Gottleber

Now, if I were to ask everybody on this call, what's the temperature outside right now? Okay, like right here where I am, it's sixty-three degrees. That's Fahrenheit, it's seventeen Celsius. You know, it depends on when you ask that question, it depends on who you ask that question to, right? That's a non-deterministic value. That makes it really hard to come to consensus, right? Because even like in this small little group here, we couldn't all agree on what the temperature is. And if you were to take an API call and get the temperature, for example, you're going to run into the very similar problem that depending on when you make that call, you could have a different value. And anytime that you could have a different value, that's a non-deterministic value, and it's a very hard to come to consensus on that.

Richard Gottleber

So understanding that, we run into a problem with smart contracts in that they, you know, provide this truth-based agreement system, they are distributed decentralized, right? Really powerful in that regard, but I kind of think of it like they live in this bubble, okay? Where in order for that decentralization to occur, they need to have deterministic values. And that kind of disconnects them from the real world, because for the most part the real world is non-deterministic, right? You can't bring in outside data easily and still maintain this same deterministic distributed system. That's a problem.

Richard Gottleber

It's commonly referred to as the 'oracle problem', right? So we have blockchains and the real world and they're kind of disconnected. I guess I'll just pause here since we are a small group. Any questions so far? Could you just dive a little bit into where you talked about the oracle problem, so non-deterministic, that's just saying that different people could call the same data point and it could yield back different information? Right, yes, yeah. So in order for the nodes within the blockchain network to come to consensus, they all need to agree on the value of whatever thing that we're talking about here, right? Like an API call or a random number that's being generated. And so that is the oracle problem, is the fact that you need some way to talk to the outside world in a deterministic fashion.

Richard Gottleber

This is essentially where Chainlink comes in. And so Chainlink is a, Chainlink provides the ability to create a distributed network of these oracle nodes so that you can then bring off-chain data and computation on-chain in a deterministic fashion. Now when it comes to oracles, it's totally possible to create your own oracle and bring data into your smart contracts. One thing to - is there a question? I think someone might be unmuted. Yeah gang, if you don't have a question could you please mute? Great, awesome. Apologies. All good, no worries.

Richard Gottleber

So you can create an oracle and bring that data on-chain, right? And if you have one node as your oracle, coming to consensus is very easy, right? Because one node can always just agree with itself because whatever it says, it'll agree with. That does kind of present a problem though because you're taking the decentralization features of blockchain and you're essentially centralizing them into one place that becomes a single point of failure.

Richard Gottleber

The way that Chainlink approaches this is by creating a decentralized network of these oracle nodes. So you're essentially, you know, your decentralized blockchain talking to a decentralized network of oracles. Each of these oracles is run by an independent operator and they are focused on providing data validation, reaching consensus, then they also have, you know, security reviewed before you can join that network and they have their performance history is stored so that it can be reviewed.

Richard Gottleber

When it comes to reaching consensus, that could seem like a problem, right? Because like we mentioned if we were to ask everybody what the temperature is, in this example here we're talking about the price of an asset, you can see each node reports a slightly different price, right? So how do we overcome this issue of coming to consensus on a price when each of the nodes could report a different price? The way that this problem is approached is each node reports the value for whatever data point we're looking at, in this case price, and each of those prices is then signed and sent into the blockchain into a smart contract where that price is then aggregated into one value that then can be used as the consensus price. So you have the decentralized network giving all their values, aggregating that value and then storing that value on-chain. Easy way to think of this is by getting the median price of the network so that way you know like one price can't really kind of like offset the price that is reported on-chain.

Richard Gottleber

This allows us to do something that we call creating hybrid smart contracts. So now we're taking the smart contract from being on-chain only and you know kind of being wrapped in that deterministic bubble where it can't really talk to the outside world, to bringing off-chain data into it as well. Hybrid smart contracts essentially like unlock the full potential of blockchains and smart contracts where now you can interact with real-world data as well. So before I talk about the different products, do we have questions so far?

Narb

Uh, are you going to dive into the topic of external adapters? Is it further down the line or...

Richard Gottleber

What do you mean by external adapters?

Narb

So the the way, well at least when I was working and studying Chainlink, the way to get the data from the outside world was to write basically this API adapter over whatever API you wanted to call, and at least a year ago they were called external adapters. I don't know if they're called something different now. Um, I can we can touch base briefly on 'Any API', which I think is what you're talking about. Possibly. Yeah, I don't know that I've seen external adapters since I started. Oh okay. We have 'Any API' which sounds like the same thing. Yeah, it's probably the same thing, probably different name. Yeah. Basically I wanted the audience to hear kind of how API data from the outside world would get to a smart contract more or less, but I think you might go into that a little bit later. Cool.

Richard Gottleber

Any other questions on what we've covered so far? Okay. So the first we're going to talk about a few different products within the Chainlink ecosystem. Data feeds, VRF which is a verifiable randomness function - if you see VRF just think random numbers - and then keepers.

Richard Gottleber

So the first one to talk about are data feeds. And this kind of touches on what you were just talking about with the bringing in outside data on-chain. Data feeds are that thing that allows you to pull outside data on-chain as the name kind of suggests, you know, a feed of data. One of the most common ones are the price feeds, which will pull in asset pair prices. This can be a coin to a fiat currency or vice versa. We'll take a look at those in just a moment. These data feeds are used to power applications like Aave, SushiSwap, Synthetix and Compound. Currently there's over sixty billion in the DeFi world that's using these data feeds.

Richard Gottleber

The price feeds are one of the ones that we like to talk about because they are kind of like a pre-built out-of-the-box ready-to-go data feed. And that's what we'll actually be looking at in the demo and you can just use them out-of-the-box, grab the asset pair and get the current price from a distributed network which is pretty cool.

Richard Gottleber

So looking at price data, and I apologize if this is small on the Discord screen, essentially the way this works is going from left to right to the various exchanges which have the in-the-moment price and data that could be different from exchange to exchange, right? The different data providers within the node network will use that exchange data, get the price, and then they will send that price into the reference or aggregator contract where it will come to a trusted price and then that can be used by user contracts referencing that aggregator contract.

Richard Gottleber

So I mentioned data feeds, price feeds. If you head on over to data.chain.link you can actually see the price feeds that we have available just out-of-the-box. And looking at one, we'll just pick the ETH USD price feed. There's a few things to point out here. The first is this is the price that the oracle network has come to consensus on currently. You can see who the oracles are that are reporting this price together and the individual prices that each of the node operators are reporting. Currently there's thirty-one and all thirty-one are reporting. In order to have what we call a trusted answer, we would require there to be at least twenty-one different nodes reporting in.

Richard Gottleber

A few other things to take a look at here. The trigger parameters are going to be what causes this price to update on-chain. If there's a deviation of half a percent or whenever the heartbeat occurs. Essentially about every hour if nothing else happens, the price gets updated. So if the price isn't very volatile, it gets updated about every hour on-chain. One thing people ask is like why is it so slow to update the price sometimes? If it's not volatile then it will be updated based on the heartbeat and that is actually taking those values and storing them in the blockchain, so there are, you know, gas fees and everything associated with doing that, and that's part of why they're spaced out.

Richard Gottleber

Another cool things about Chainlink is if you wanted a data feed that was updated more frequently, you could do that, you could create one. So that's one of the really cool things. A couple other things to look at on this page. The contract address - this is going to be where this information is actually stored on the blockchain. We'll be taking a look at one of the contract addresses in the demo in a little bit. You can also access this contract via ENS.

Richard Gottleber

You can see the history and volatility based upon the trusted answer and then you can get more information about the nodes. So before we go on to the next bit, any questions so far? Can anyone set up one of these data points, like for the heartbeat and the trigger parameters? Is anyone able to go and create their own data feed or is there a process for that? I'm just curious.

Richard Gottleber

Yeah, so in order to create that you will need to have a node, right, in the network that you're working with or operating yourself. Anyone can set up a node and operate it. Does that answer your question? Yeah I was just curious. Thank you. Yeah.

Narb

Uh I have a question around why the number twenty-one for the amount of nodes to come to consensus? Is that just like out of like studies or research or... Um that's just the number that seems like a good number based upon the number of oracles that we have in total. Gotcha, gotcha. Good question though.

Richard Gottleber

Alright, how strict are we on the time limit? We're aiming for thirty minutes, you got ten minutes. Ten minutes, okay cool. The next thing to talk about is Chainlink VRF. So that's going to be the verifiable randomness function. Again, you see VRF just think random numbers, it's a lot easier than trying to remember what VRF stands for in my opinion. Essentially random numbers are hard to be deterministic again, right? Like if I ask you to come up with a random number, it's probably going to be different than if I come up with a random number. And why it's important to have the verifiable piece of random numbers is that it's possible to impact the random number that's being generated when you generate a random number on-chain, because typically on-chain, thinking through tutorials and examples I've seen, what normally happens is you take some sort of seed or a hashing function, whether that's the address of the person calling the function, the block hash that you're creating the random number in, maybe the time that you're creating the random number, right? Something that you know going into it what the seed is, is then hashed to create a random number.

Richard Gottleber

Just to make this like very simple, if we were thinking about, you know, just like a coin flip random number, right? So like we take the hash as odd or even, that's going to be the results of our coin flip. A miner could look at that result and see 'Is this going to be what I want it to be, yes or no? If it is, cool, I'll mine this block and add that random number to the block. If not, I'll wait.' Something like a coin flip may or may not seem like, you know, there's incentive there, but when you start thinking about things like lotteries where there's, you know, millions of dollars on the line and we're talking about picking the winner of the lottery, now it becomes, you know, you're starting to incentivize people to maybe do malicious activity.

Richard Gottleber

Where Chainlink comes in here is using the distributed oracle network, those oracles can create a random number off-chain in a verifiable fashion and then pass that into the contract on-chain so that you have a verifiably random number that is then verified by the smart contract and then can be used by subsequent contracts on-chain. So again, we're taking that distributed network, creating a random number that is verifiably random so you know there was no funny business going on, passing it into the blockchain and you can use it on-chain.

Richard Gottleber

This is being used by projects like PoolTogether and Aavegotchi. PoolTogether uses it for selecting a lottery winners, Aavegotchi uses it for random traits when you're creating the NFTs. PoolTogether, I just have to take a moment, is like really cool, I don't know if everybody knows about that but I think it's really interesting concept of like the no-loss lottery where you put your money in, they get the yield or interest from it and that's what the winner of the lottery wins and everyone else gets their money back. Like I don't know, that's really kind of a cool idea. Yeah, so that's what VRF is, it's basically creating random numbers in a verifiable fashion and then passing them into the smart contract where they can be used on-chain.

Richard Gottleber

The next one that we're going to talk about, unless - sorry, are there any questions about VRF? Alright. The next thing that we're going to talk about are Chainlink keepers. Keepers are I like to think of them as off-chain compute that you can bring on-chain. A lot of what I've seen done with them is something like cron in the Unix environment, or 'if this then that'. Essentially you can set up parameters to trigger your smart contracts. This is one of the coolest use cases I've seen. Smart contracts are great, despite their name of being smart they don't do much by themselves. They need something to like, you know, kind of kick 'em off. And that's where keepers come in. You can have events that trigger actions within a smart contract, you can have time-based triggers for smart contracts.

Richard Gottleber

And essentially what happens is you talk to the oracle network and you pass in a set of parameters to trigger an event happening within a smart contract and the keepers will then watch for that event to happen. If you remember on the data feeds, these trigger parameters, these are essentially being done by keepers, right? If the threshold is met, that will trigger the smart contract to update, or when the heartbeat threshold is met, that will trigger the smart contract to update. Keepers can be used for things like automating contracts, basing values, harvesting yield, triggering any other event that you want to on-chain. Question so far? Next up is demo time. Five minutes.

Narb

I guess quickly, so are those triggers set up off-chain or are they on-chain? So they are set up with the oracle node network. Okay. Is that through some UI or can we do that? Yes, yeah. Cool, cool.

Richard Gottleber

Cool. So go through a quick demo. I think I can get through it in less than five minutes. We're going to head on over to the docs, look at the price feed docs, go from there to Remix and then we're going to deploy a contract on-chain that will use the price feed aggregator data on the Kovan test network. So head on over to docs.chain.link. This is the home for everything documentation related, like if you need to know anything about Chainlink it's probably here. They're broken down into EVM chains like Ethereum, Solana and Terra. If we head to the data feeds portion and using data feeds, you can read about them but right here we have an example of using one of the data feeds. Open in Remix. I don't know if everyone has used Remix, but Remix is awesome. Online IDEs like this just blow my mind. I don't know, been in the tech space for a while and anyway, it's crazy how awesome this is.

Richard Gottleber

Looking at this contract real quick, and if you have questions after I'm happy to stick around, but just trying to keep up with the time. We import in the aggregator interface, which is as I mentioned it takes all those responses from the individual nodes within the node network and then it's going to aggregate the price down to one value. We're going to create a contract called PriceConsumerV3, we're going to create a price feed that is an aggregator interface. Here we have an address of the contract that we're going to be using. If you go back to the docs, you can see there's contract addresses and here we have all the different places that the data feeds are available. Looking at the Ethereum data feeds, you scroll way down there's a lot of different asset pairs. You see on the Kovan testnet, and then we're using the ETH USD one. So that's the value that we're putting in here is the actual address of that contract.

Richard Gottleber

And then we're going to create a function called getLatestPrice. It's going to return quite a few values. We are really interested in 'price' which is going to be the price from the latest round, the last time that it was updated on-chain. And we're going to return that price. So from here, if we go to our injected Web3, just so it's pulling the data from our wallet and we make sure that we change the contract - I don't know how many people on here use Remix but this is one of my biggest gripes about it is that I always forget to change the contract and deploy the wrong thing and it's terrible and embarrassing, especially when you do it in front of people.

Narb

Been there.

Richard Gottleber

And then you're like, why is this not working? Yep, yep. You can see here we have a deployed contract of our PriceConsumer with the function getLatestPrice. Click that and we get the latest price of ETH and I know you might be thinking 'Oh man, if that's what ETH's at, I get to quit my job right now, right?' Solidity doesn't do decimal places, so we've essentially injected eight decimal places into this price. So we need to put a decimal here to get the price in USD, and so you know it's like thirty-one hundred dollars. And just like that we have deployed a contract to the blockchain that interacts with a distributed oracle network to get the price of ETH in USD. Pretty quick.

Richard Gottleber

So we've talked about smart contracts, why they're awesome, the oracle issue or oracle problem. We've talked about data feeds, VRF and keepers. And we went through a quick demo of getting a contract deployed. Clean out. If you want to hang out and talk with us we have a Discord. We have some starter kits on GitHub that'll get you up and running with like the basics of everything you need to start doing smart contract development. We've looked at the docs and then we have a new Chainlink Academy that kind of walks you through an introduction to blockchain space and development. Questions? I did it! On time! Yes! Five seconds spare.

Narb

Yeah this was awesome Richard, thank you so much for doing this. This was very, very, very valuable information and I know Chainlink is going to be a really important piece in our ecosystem as we continue to build. So yeah. And does anybody have any questions for Richard?

Richard Gottleber

I have a quick question. Yeah thanks so much Richard for your presentation, great. I've been curious about Chainlink for a while. What is the - how does the pricing and all that work? I heard there was some kind of coin or something or how do you pay for the service?

Richard Gottleber

Yeah, so that's a 'it depends' question when we talk about paying for the service. The price feed data is available and out there and anybody can use it. That doesn't mean that it's free to create. Going back to the data.chain.link, if you look at a price feed, towards the bottom you'll see a area where you can see the users. These are essentially I like to kind of think of them as sponsors of this price feed. If you are using a price feed in your project, right, it becomes beneficial to ensure that that price feed is reliable, it's going to be there and that, you know, the data is high quality, and high quality data normally doesn't come for free. So these different projects companies are essentially sponsoring this price feed.

Richard Gottleber

You mentioned that you have heard there's like a coin? Yes, there is a LINK token and that is used just within the network to essentially pay for services, right? Pay for the time that the oracles are doing things for you, kind of similar to gas. One really cool thing about the LINK token is that it has a 'transfer and call' method within it, which essentially allows you to not just transfer it to an oracle node when you want the oracle node to do work for you, but to also call a function as you transfer it. So that's one of like the kind of really powerful unique things about the LINK token and like why we don't just use something like ETH. Also Chainlink is chain agnostic, right? So having a token that is within the Chainlink ecosystem makes a lot more sense there. Does that answer your question?

Richard Gottleber

Yeah that's great. So would you - you would buy an amount of token just in your like account and then like how would you keep the token funded?

Richard Gottleber

Yeah, so this is again slightly depends. When you call to get like a random number, for instance, you will need to supply LINK token there. You can fund your contract with LINK token, so you can pass LINK token to your contract that's going to be calling the random number function and so as long as your contract has LINK token in it you can continue to call that random number function. Awesome, well thanks so much! I look forward to checking this out. Yeah. Other questions?

Richard Gottleber

When you have - this is a really great presentation by the way, I learned a lot so thank you so much for doing this because this has been awesome. Just a question on the users. Do they sort of is there like a pool where LINK goes into an aggregate and then like is that like a financial incentive to be a user or a sponsor of a certain data feed or I guess like what what would incentivize people to support different data feeds? Maybe over another, is there like a competition in that sense to create the most validated data feed? Or am I thinking about it the wrong way?

Richard Gottleber

I'm not sure I'm fully understanding your question. Um I was just wondering like if there were like two ETH USD data feeds, right? Is that what you're referring to? Yeah like yeah that's kind of what I'm asking. Yeah, so as far as incentive to join one over the other, I guess I would kind of ask the question to you. If you had a data point that had five sources of truth for that data point versus two, which one would you opt for using? I'm not sure I'm fully understanding your question here but like the more sources of input into the like the more distributed, right? The network is, the more nodes there are reporting a certain data point, the more reliable it is. Does that - I'm sorry if I'm not fully...

Richard Gottleber

Yeah I was just wondering like how users like sign up to basically sponsor a certain data feed or what would make a certain company want to - you had like 1inch on there like I was just curious like what 1inch might want to support the ETH data feed as opposed to I don't know another type of data feed. Right, so I think that what that boils down to is if you're using it within your project, you're kind of incentivized to ensure that that price feed is reliable, it's going to be there and that, you know, the data is high quality. Is that answering your question? Yeah that's exactly what I was wondering, yeah I was kind of curious what makes a company want to be a user of a data feed. So thanks for explaining I was just kind of wondering how companies aggregate together to support it but it's to create decentralization yeah and support the network. Thank you.

Richard Gottleber

And part of part of the reason like I think this is kind of like a inbuilt piece of blockchain with it being transparent is that, you know, once you've done the work to get that data on-chain, it's there anybody can see it, right? And so that's kind of where like the price feeds are available for anyone to use because that data is there and anyone can see it. Really appreciate it, thank you so much! Sure. Any other questions?

Narb

Uh I see that we are a bit over time, but feel I'll just stop the recording and but you guys can all chill and and ask Richard any other questions you may have. So I'll just finish up the DevNTell here. So thank you again Richard, this was a very valuable session. We all learned a lot and got us giddy to to go out and play with Chainlink. We do have that hackathon coming up, right? So it's something to look out to use, right? So at the end I'll post a excel sheet, a Google Sheets rather, that you can claim your POAPs for for attendees, and Richard I'll send you your speaker POAP through DM. But once again thank you very much everyone for coming, I hope everyone has a fantastic rest of the day, a great weekend and we'll catch you back here next week. And with that I'll stop the recording.

Listen On

Resources & Links

Share This Episode

Share on X

Watch Episodes Live!

Subscribe to our event calendar and never miss a live episode.

View Event Calendar