chainlink letters how many drcimals in chainlink link token chainlink problems Hybrid Smart Contracts and Decentralized Oracle Networks ft. Chainlink Avalanche Summit 2022
today we are going to discuss the hybrid smart contracts what are they exactly and the importance of decentralized oracle networks so as i said in spanish my name is andrei rakic and im a developer advocate for training protocol at training clubs you can see here listed my twitter handle my email but ill be here during whole week including hackathons so feel free to reach me out in person to talk anything channeling related so lets start with the agenda in the next 30 minutes we are going to discuss the oracle problem and how channeling solves it we are going to have a little code along where were going to create some simple d5 app using training price fits on avalanche and finally i will have some exciting news for you so be sure to stay until the end of presentation we have some news okay so to understand the oracle problem we need to take couple of steps back to understand the purpose of smart contract okay so we all know what smart contracts are i wont bother you explaining them but we really need to understand which problem smart contract solves and thats the problem of trust so with the traditional agreements theres always some third party or so-called com contract operator which both parties of the agreements need to trust so thats the problem because that third party of our contract operator can have some common interest can have something you know um in that agreement that its really for him right so it doesnt matter whether youre going to trust the brand the company the logo the paper some individual it doesnt matter with traditional agreements theres always a need for trust to that third party and smart contract or so-called digital agreements solve that that problem because they rely on cryptography and blockchain as underlying technology so you actually dont need to trust anyone because all of the term sheets are written inside the smart contract itself they cannot be changed they cannot be modified deleted corrupted in any way so whats written there stays there forever right so you remember that some protocol which banned user to trade game stocks when they need the most thats not possible with smart contracts but smart contracts also are not perfect they have their own problems they have their own flaws so one of the biggest problems smart contracts has uh is that so-called smart contract connectivity problem so smart contracts live in their own isolated environment in their own blockchain theyre currently deployed and they cannot access any kind of off-chain data so smart contract cant know whats the current market price of any given token or coin smart contract cant know whats the current weather here in barcelona smart contract cant know who won in the latest el clasico is real madrid is his barsa smart country cant know that and the solution to the oracle or smart contract connectivity problem is channeling protocol so chainlink is a decentralized oracle network consists of independent nodes which serves as a middleware layer for blockchains no problems to provide to smart contracts any kind of off-chain data in a trust in a secure manner so chain-link is not a blockchain its a decentralized oracle which only needs to reach consensus and thats it anyone can run the node and become a node operator in trailing network because everything is open source and free to the community you can just check it out and its and its thats it so but what happened if you have a centralized oracle right so youre at risk to not to receive inaccurate data or no data at all thats why one of the main focuses of chaining protocol is decentralization so chainlink is consists of full replicas run by independent and civil resistant node operators so the main focus of channeling decentralized oracle network is data validation consensus and security and to answer the main topic of this talk what our so-called hybrid smart contracts in one sentence we can call it like this so hybrid smart contract is any smart contract which combines both off-train and on-chain data and computation and they are really powerful okay so how many are you are going to attend to the hackathon is there any hackers here oh quite a lot so for the purpose of this talk i wrote a simple smart contract so this is the simplest decks ever written you can see theres only two token addresses uh stored as a storage variables so this my dax can can hold only one pair of one liquidity pair and thats it so it has add liquidity function to add some initial liquidity to this dex he has this swap function to swap a given amount you see its a function parameter to swap from these two tokens and has this view function to get the swap price its a simple matte function you multiply the initial amount with the current balance of destination token in the pool and divide that value uh with the current balance balance of from token from that pole and now imagine that you want to build some d5 protocol during the hackathon on top of this these decks why its not a good idea to use this this get swapped price as your source of truth when you want to get like whats the price of token inside this dex can anyone can anyone like discuss this with me speed i mean thats not the main concern here yes exactly yeah so hes right this is a vulnerable smart contract so you can manipulate the price uh either by adding enormous liquidity to one side of the pool either by doing in ones block you know serious of as as he said swaps to actually dry drain out one side of the pool and eventually we have have like one or zero as the value as a price and this is not the correct price so i deployed this renewable contract to the avalanche fuji test net so if you want to play with it sure uh i added initial liquidity 10 link tokens on avalanche and 10 wrapped avex token an avalanche fuji testnet so this is the initial liquidity to this smart contract if you were able to drain drain the funds of one token for example uh you can come visit our booth with proof of transaction we can give you some extra swag but what else uh imagine that now you have some really good decentralized exchange like it has protections against all of these date attacks its not vulnerable et cetera et cetera white still isnt a good idea to use any kind of dex as your source of truth when its come to the prices the problem is it never mind either thats a dex or a tax or c5 protocol or binance whatever like its still a centralized solution its still the centralized the centralized root of of price so you get the price for from only one data provider whatever the name is so even if you you know you cant for example hack these decks to change prices in one block its still you get price from one single point and we are in the decentralized world we want to minimize the single point of failures thats why chaining data fits comes in so with chaining data fits each node can have their own source or sources of truth when it comes to the prices so imagine this slide okay so i want to ask whats the current price of avex token at the moment so each of these nodes can have their own source or sources of true the price so one of these nodes can use my vulnerable decks to get the price but eventually this decentralized oracle network needs to reach a consensus to provide the correct price of a token to the calling contract and nodes have the incentive to do the honest work because they can earn linked tokens if they do the bad work they can be punished uh to use you know in your hackathon whatever project you want channeling feeds its really easy so you know need to go to data.train.link to find to find all of the aggregators possible and then go to the train dot link you will have uh you will then there find one simple code snippet so its really a one function which you can you know use to get the latest price and thats it you can build on top of this and many notable projects already are using data fits okay so i said that i will have some exciting news for you for hackers thats why i ask you to to raise the hand so we were asked about this a lot a lot during previous six months of one year on our from the community members on our discord twitter github issues stacker overflow questions and finally i have the opportunity to finally announce that chainlink vrf with 2 is finally available on avalanche fuji testnet so you will have the ability to be the first one to actually try to integrate the new vrf v2 on avalanche fuji testnet this is still in beta so its not available on mainnet yet and theres no uh that fancy ui for creating a subscriptions because its a beta but i will now show you how you can do it from your smart contract so i think you you will handle out because like youre participating in a hackathon so before that uh you uh to or to see all all of this which im going to show you like right now go to docs.chain.link slash a v a summit without x docs chain dot link slash ada summit you you on that url you will have the ability to see uh pardon to see this page so this is the official docs page for just for avalanche summit for hackers so once again dogs the chain.link slash avi summit and you will have the step-by-step uh tutorial how to use vrf v2 on avalanche fuji testnet and thats what we are going to do right now so if i scroll down a little bit this is the code so you can see that uh inside the constructor is going to create a new subscription so uh on for example some testnet on where the ui is available you you can go to the ui connector wallet and click create subscription we are going to create subscription here you you can uh create these subscriptions through ether.js as well so its its up to you how youre going to call the smart contract or we uh block explorer whatever but you need to create a subscription uh after that you need to fund that subscription and finally to add some consumer contract you know you are already deployed smart contract so ill just now going to scroll down a little bit this is all of the parameters you need to know and if i click here its going to open this contract inside the remix id so im inside the remix id with this contract and i will going to deploy it to to avalanche fuji testnet we injected web provider okay i just need to click confirm and wait for for the transaction to be mined so this is the first step you need to deploy your smart contract and its going to create a subscription so lets go back to this uh doc so after compiling and deploying you need to fund your smart contract with at least two test net links so to get test net links uh you need to go to forces forces.chain.link select avalanche fuji testnet connect your wallet and you will get 10 link tokens its free for you so what i need to do now is to find my metamask i hope you can see this i need sorry i need the destination address right for funding ok copy address so small link send okay paste my address here as i said tooling tokens thats enough and click next finally i need to sign this transaction of course and we need to to wait to this transaction to be mined right okay i think and true cool and finally what i need to do is to call this top-up subscription function so this is just for avalanche test net because there is no ui uh so this top-up subscription just look at their implementation is pretty much same as like click add consumer contract in the ui and thats what im going to do now its going to fund this smart contract with you know uh two test links so this is my balance top up subscription click transact once again i need to sign this okay lets wait for the transaction to be mined is it mind yeah it is i think so yeah it is and finally i need to call this request random words so dont be confused by the naming words are stand for uh words in computer science so bit wise words its basically going to return you int 256 value random value so one great power also of vrf v2 is that i can specify how many random numbers i want to random values i want to get as a callback from decentralized oracle network with the previous version of erf you know that you can only get one random number in one single transaction and then you need to manipulate you know module values to get more of this now you can specify how much do you want and you you will have the array of random words which is going to be populated in a fulfill requirement function so uh its so small here sorry so finally i need to call where it is request random words and i need to sign this transaction confirm and thats it right now im waiting the transaction to be mined im awaiting a callback from the decentralized oracle network so they need to reach out consensus and send me like the the random value and thats it uh okay so just theres also a helper function inside this uh this uh contract uh dip yeah pending requests so theres no pendulum request is false so lets uh get the random values whats the random number zero this is the random value i got as a callback from the centroids oracle network one this is the second so i got two random numbers in a single transaction call okay i will just be here and we can continue with this with the slides so this was the vrf we do an avalanche test net avex fuji but we have even more exciting news for you whos going to participate in a hackathon training keepers are also now available on avalanche fuji starting today you can use chain link keepers on avalanche fuji test net with chain link keepers uh its a completely the same experience as a as on the other chains so you need to create the keeper compatible contract uh keeper compatible contract means that you need to implement keeper compatible interface which consists of only two functions so one is check up keep which is often times the view function and returns like true false so basically on each block or each time frame depends on the chain the the keeper keepers are going to ask your smart contract do you need something for me do you need some optimization from me if uh checkup keeps returns false nothing happens if check hopkins returns true uh automatically perform upkeep function is being called so maybe its easier with it so perform upkeep functions being called and some work is bad then being initiated by the chain link keepers so with training keepers you can watch this uh this slide over here so if you go to keepers.chain.link website you will have the ability to switch to avalanche fuji testnet and thats it simple as that so were not going to demo like keepers because everythings the same you just need to go to keepers the chain.link and select avalanche fuji basically the same thing you can find in the docs and the one last thing before questions i want to remind you sorry that the submissions for chaining spring 2022 hackathon are officially open so this is going to be the biggest trailing hackathon so far you can compete for cash prizes and no cash prizes currently there is like more than 300k in prices from various sponsors uh there will be also a ability for you if you create some really good project or mini startup to be invited to a vc pitch demo and also some of the notable judges will be sergey nazer austin griffey patrick collins and many more and whether youre just entering the web three space or you think you have the whats necessary to win the grand prize make sure to sign up now at hack the train dot link for the new commerce we will have tons of educational content uh streamed online on our youtube channel from our developer advocates from the beginning you know like creating a first smart contract to the more you know complex topics like creating your own chain da or something like that so where to start from now you can join either our discord chat so this is the link for our discord to chat with the community members and also with chain link employees chain of clubs employees so you can go to smart contract kit organization on github to find some boilerplate starter kits to build on allen so we have a start kit for truffle for hard hat for brownie for daptoes for foundry uh its its really up to you which one youre going to choose basically theres the code examples how to use chain link in your smart contracts and as well how to test them properly recently we also added a fuzz testing to our brownie and uh starter kit so make sure to check this out obviously the first step youre going to take when you try to integrate chain link is to go to our official documentation so dogs the chain.link and finally if youre a beginner go to training academy to sign up for even more educational content so for once who is going to participate in hackathon again if you want to use chain link go to docs the chain.link slash ava summit you will find all of this uh this url on this page which i demonstrated right now so that will be it we have eight minutes for questions so if anyone has a question feel free to raise your hand i will try to to answer it yes uh yeah so uh officially theres no limit but you can uh get out of guess exception so thats because you need to populate the storage and thats thats a costly operation because s s stories takes a lot of gas and uh what was the cost uh yeah so costs are described on the official docks regarding you know or which train you are and stuff like that so you can switch between chinese uh there are currently a couple of uh chains that supports vrf32 not all of them but you know i dont have the information about the timeline so thats it currently its an avalanche last night uh okay two questions i assume youre just uh are you trying to find a way to give to your network uh a way to to answer to to questions that you currently dont doesnt support yeah sure i mean i mean something decentralizing this also so you have not the way to uh something random that um like uh well um well drain to tomorrow in this city okay so we actually had something yeah so thats called any api so you can check that on our docs its basically a way to create a http get request from your smart contract you need to hard code basically the url youre wanting to to to put to you know reach out theres a you need to find the proper job on market.link for your purposes but you know on testnets its really easy to try because you can basically copy paste the whole thing from our docs and i participate in one training hackathon years a year ago and im created a dap which going to which does some uh betting on who is going to win the euro 2020 that was in football so which country you know is going to i needed uh odds from the markets at that place so i use any api for that purposes uh yes yeah so how would you compare chain link to uma protocol thats a different yeah oracle you know im not an expert in uma so i dont know like their advantages disadvantages are chaining but its basically up to you to try it you know to verify it and that thats it you know yes running for c chains or x chain as well i think its only for c chain but i will get back to you it was latest notice yeah okay are we good on time any questions no thank you very much [Applause] Hybrid Smart Contracts and Decentralized Oracle Networks is the topic presented by Andrej Rakic Chainlink during the 2022 Avalanche Summit in Barcelona. Rakic talks about the purpose of smart contracts, the Oracle Problem and how to solve it, the release of Chainlink VRF V2 on Avalanche Fuji, and other subjects of importance.To learn more about Avalanche, please visit Avalanche Summit is a conference for developers, researchers, and makers building on Avalanche. Learn about the latest Avalanche platform updates, and meet like-minded innovators creating the next-generation apps for Web3. Avalanche is the fastest smart contracts platform in the blockchain industry, as measured by time-to-finality. Avalanche is blazingly fast, low cost, and eco-friendly. Any smart contract-enabled application can outperform its competition by deploying on Avalanche. Don’t believe it? Try an app on Avalanche today. Avalanche Resources: Website: Ecosystem: Twitter: Discord:
movimientoantipiquetero.com.ar