Dev & Tell | Richard Gottleber (TheRG) - What is Chainlink?
Developer DAO · 11 Feb 2022 · 38:08
Richard Gottleber, a developer advocate at Chainlink Labs and early Developer DAO member, explains what oracles are and what Chainlink brings to blockchains. He moves from trust-based to truth-based agreements, then shows why smart contracts need deterministic data and how this creates the oracle problem. The talk covers decentralized oracle networks, how node reports are aggregated into one on-chain value, hybrid smart contracts, and Chainlink products such as data and price feeds, verifiable randomness and keepers, with audience questions on external adapters and who funds feeds.
Speakers
Topics
From Developer DAO; community: Developer DAO.
Transcript
gag gang welcome to what's going to be another great devontel oh if you didn't know devontel is a 30 minute window for members of the dow to showcase something they're passionate about or i've been working on this could be an awesome project we'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 with the community and today i'm happy to introduce richard who will be going over decentralized uh oracle networks for us specifically chain link over to you richard perfect thank you for the introduction so yes i am richard gottlieb i'm a developer
advocate at chain link labs um i guess just for the purposes of the dow like i joined developer dalek when it first started and it was really a jumping off point to getting to be a part of chain link labs which is awesome um i don't know the 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 um my twitter's there my email's 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 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 chain link 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 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 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 but most of the time even though here it's very rare for that to happen still a problem and having this kind of like trust-based agreement system is problematic right
you end up with things where um in the past certain investment firms have decided you know that you can't trade anymore right now 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 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 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 are decentralized as well and in order to have a network where you have various nodes all are agreeing on certain things it has to be what's called deterministic so
we're a pretty small group i'm going to ask you questions if you want to just like chime in with answers that'd be awesome um so talking about deterministic values does anybody know what one plus one is are we talking javascript is it 11 no one plus one right like integers one and one what is it it's two right we can we can all agree like jokes decide about javascript but like that's a good point we can all agree that like you know if you add you know integer one and integer one you're gonna 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 two agree that's awesome now if i were to ask everybody on this call what's the temperature outside right now okay like i'm right here where i am it's 63 degrees that's fahrenheit it's 17 celsius no it depends on when you ask that question 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 any time that you could have a different value that's a non-deterministic value it's very hard to come to consensus on that so understanding that's 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 you 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 it's commonly referred to as the oracle problem right so we have blockchains in the real world they're kind of disconnected i guess i'll just pause here since we
are a small group question so far could you just dive a little bit into um just the just we're talking about like the oracle problem so non-deterministic that's just thing that different people could call the same data point and it could yield back different information um is that kind of right what you're saying yes yeah so so um in order for the nodes within the blockchain network to come to consensus they all need to agree on the value of everything that we're talking about here right like an api call or a random number that's being generated and so that that is the the oracle
problem is the fact that like you you need some way to talk to the outside world in a deterministic fashion is essentially where chain link comes in so chain link is a chain link provides the ability to create a distributed network of these oracle nodes but you can then bring off chain data and computation chain in a deterministic fashion now when it comes to oracles it's totally possible to create your own oracle and
bring into your smart contracts one thing is there a question i think you might be unmuted yeah again if if if you don't have a question could you please meet great awesome apologies oh good no worries 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 the way that chain link approaches this is by creating a decentralized network of these oracle nodes so you essentially have 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 valid data 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 they can be reviewed 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 and each of the nodes could report a different price the way that this problem is approached is
each node reports the value or whatever data point we're looking at in this case price 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 then can be used at the consensus price so you have a 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 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 or bring off chain data into it as well every smart contracts essentially like unlock the full potential of blockchains and smart contracts right now you can interact with real world data as well so before i talk about the different products we have questions so far uh are you going to uh dive into the
topic of external adapters is it further down the downline or what do you mean by external adapters so the the way well at least when i was uh working and studying chain link the way to get the data from the outside world was to write basically this api adapter over whatever um 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 basically yeah uh briefly on any api which i think is what you're talking about uh possibly possible um
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 okay yeah basically uh uh i wanted uh the audience to hear kind of how uh how the how api data from the outside world would get um to a smart contract more or less but i think you might go into that a little later yeah cool better questions on what we've covered so far okay
so the first we'll talk about a few different products um within the chain link ecosystem beta feeds vrf which is a very verifiable randomness function if you see vrf just think random numbers and then keepers so the first one 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 um 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 ave sushi swap synthetics and compound currently there's over 60 billion in the default world that's using these data feeds hey because i don't know how to describe the uh price feeds are one of the ones we like to talk about because they are kind of like a rebuilt 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 in a from a distributed network which is pretty cool so looking at ice data and i apologize this is small on the discord screen essentially the way this works is going from left to right the various exchanges which have the you know the moment pricing data it could be different from exchange to exchange right different data providers within the node network will use that exchange data get the price and then they will send that price in to
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 so i mentioned data feeds price feeds if you head on over to data.chain.link you can actually see the price feeds we have available just out of the box um and looking at one let's pick the usd price feed there's a few things to point out here 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 31 and all 31 are reporting in order to have what we call a trusted answer we would require there to be at least 21 different nodes reporting in a few other things 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 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 i guess 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 that's part of why they're spaced out one of the cool things about chain link is if you wanted a data feed that was updated more frequently you could do that you could create one um 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 the 100 addresses in the demo in a little bit you can also access this contract via ens 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 bits any questions so far can anyone set up one of these data points like for the heartbeat and the um like the trigger parameters is anyone
able to go and create their own data feed or um is there a process for that i'm just curious yeah so in order to create that you will need to have a node right in the network that you're working with um or operating yourself anyone can set up a node and operate it to answer your question yeah i was just curious thank you yeah uh i have a question around um uh why uh why uh the the the number 21 for the amount of no's 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 got you yeah good question though right how how strict are we on the time limits uh we're aiming for 30 minutes uh you got 10 minutes 10 minutes uh what 10 minutes okay cool um the next thing to talk about is chain link vrf so that's going to be the verifiable randomness function um again you see vrf just think random numbers
it's a lot easier than trying to remember what vrf stands for in my opinion um essentially random numbers are hard to be deterministic again right like you know 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 unchain 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 um 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 hash to create a random number um 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 results 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 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 to be you know you're starting to incentivize people to maybe do malicious activity your chain link 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 is verifiably random so you know there was no funny business going on passing it into the blockchain and you can use that on chain this is being used by projects like pool together and avogadchi pull together uses it for selecting the lottery winners avagashi uses it for random traits when you're creating the nfts um i don't know pull together i just have to take a moment it's 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 euler interest from it 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 um yeah so that's what vrf is it's basically creating random numbers in a verifiable fashion and then passing them into a smart contract where they can be used on chain the next one that we're going to talk about unless sorry are there any questions about vrf all right next one and we're going to talk about our chain link 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 um despite their name of being smart they don't do much by themselves they need something to like you know kind of kick them 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 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 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 smart contract to update so keepers can be used for things like um automating contracts pacing values harvesting yields triggering any other event that you want
to unchain questions so far next up is demo time five minutes uh i guess quickly uh so are those uh triggers um set up uh off chain or are they on chain they are set up with the oracle node network okay is that through some ui or can we do that uh yes yeah cool cool 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 uh 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 uh in covin 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 chain link it's probably here um they're broken down into evm chains like ethereum solana and tara 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 in remix
i don't know if everyone has used remix but remix is awesome um i don't know like online ides like this just blow my mind i've been in the tech space for a while and anyway it's crazy how awesome this is uh looking at this contract real quick and if you have questions after i'm happy to stick around but just trying to you know keep up with the time uh 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 it's going to aggregate the price down to one value um we're going to create a contract called price consumer v3 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 data feeds are available looking at the ethereum data feeds scroll way down there's a lot of different uh asset pairs see on the coventestnet 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 um and then we're going to create a function called get latest price it's going to return
quite a few values uh we are really interested in price which is going to be the price you know from the latest round the last time that it was updated on chain and we're gonna return that price so from here if we go to our injected web3 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 in 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 in front of people you've been there and they're like why is this not working
yeah um you can see here we have a deployed contract of our price consumer with the function get latest price we click that and we get the latest price of eth and i know you might be thinking oh man if that's what you set 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 price or a decimal here to get the price in usd and so you know it's like 3 100 just like that we have deployed a contract the blockchain interacts with the distributed oracle network to get the price of eth and usd
be quick we've talked about smart contracts uh why they're awesome oracle issue oracle problem we've talked about data feeds vrf and keepers and we went through a quick demo of getting a contract deployed now if you want to hang out and talk with us we have a discord uh we have some starter kits on github that will get you up and running with like the basics of everything you need to start doing smart contract development go to the docs and then we have a new chain link academy it kind of walks you through an introduction to blockchain space and development yeah this was awesome richard thank you
so much for doing this uh this is very very very valuable information and i know chain link is going to be a really uh important uh piece in our ecosystem as we continue to build um so yeah and does anybody have any uh questions uh for richard and a quick question um yeah thanks so much richard for your presentation great it's i've been curious about chain link 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 or how do you how do you pay for the service 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 anybody can use it
it doesn't mean that it's free to create um going back to the uh data.changelink 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 um 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
you mentioned that you have heard there's like a coin yes there is a link token and that is used um just within the network to uh essentially pay for services right uh pay for the time that the oracles are doing things for you kind of similar to gas um 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 to also call a function as you transfer it but 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 um inlink is uh chain agnostic right so having a token that is in the chain link ecosystem makes a lot more sense there to answer your questions yeah that's that's great um so would you you would buy an amount of token just in your like accounts and then um like how would you keep the token funded yes so this is again um slightly depends when you call to get like a random number for instance
you will need to supply a link token there um 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 checking this out other questions 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 um just a question on the users
are 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 um a certain data feed or um i guess like what would incentivize people to support different data feeds um maybe over another like is there like a competition in that sense to create the most validated data feed or um am i thinking about it the wrong way i'm not sure i'm fully understanding your question um i was just wondering like if there were like two data feeds and like one has five sponsors or users and then the other one has like two
is there an incentive to join the one that has five over two or do both data feeds like work the same um if i understand what you're asking so if you have like two eth usd data feeds right is that what you're for example yeah like yeah yeah so as far as incentive to join one or 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 um
you know like it kind of is a i don't know 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 is that i don't know i was just wondering like how how users like sign up to basically sponsor um a certain data feed or what would make a certain company wanna like you have like one inch on there like i was just curious like what one inch might want to support the eth data feed as opposed to like i don't know another type of data feed um right so i think what that boils down to is if you're using it within your
project um you're kind of incentivized to to ensure that there are um more nodes in the network so it's more reliable and decentralized is that answering your question oh 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 curious yeah yeah it's kind of uh if you're if you're using it within your project then it makes sense to um make sure that it's it's there right like i feel like i'm not answering that question well but i think i think we're good yeah if you're using like the compute in a sense like you'd want to be sponsoring the network to make sure that it's there
and other people can benefit from it too and then by them supporting it then it creates a network oh yeah long-winded question but thank you for uh preparing with me i was just kind of wondering how companies aggregate together to support it but it's to create centralization yeah right the network yeah thank you and part of part of the reason like i think this is kind of like a inbuilt piece of blockchain with it being uh 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 that date is there and anyone can see it i really appreciate it thank you so much
here any other questions i see that we are uh a bit over time um but uh a few i'll i'll just stop the recording and uh but you guys can all uh chill and ask uh richard any other questions you may have so i'll just finish up the dev until here uh so thank you again richard uh this was a very valuable uh session uh we all learned a lot and uh got us giddy to go out and play with chain link uh we do have that hackathon coming up right so uh it's something to look out to use right uh so
uh at the end uh i'll post a uh excel sheet uh a google sheets rather that you can claim your pull-ups for for attendees and richard i will send you your speaker co-op through dm but once again thank you very much everyone for coming uh 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 record
