Chainlink 🛠Smart Contracts connected using Chainlink Functions and CCIP
ETHGlobal·Wed, Oct 9, 2024, 12:00 AM
A Chainlink workshop! Embark on a journey with ETHIndia, where innovation thrives, collaboration knows no bounds, and hierarchies fade into self-sovereign ownership. The most skilled web3 developers, designers and product builders from all around the globe came together for a weekend-long adventure to advance the Ethereum ecosystem at ETHIndia in December of 2023! ----------------- Follow us: https://x.com/ethglobal Check us out: https://ethglobal.co​m Email us at: hello@ethglobal.com
Transcript
[Music] so another important point for you this is the care code of the presentation so read this care code now and then everything that we are showing to you later you don't ow about it because you can have everything in your own computer so I can give you one more minute to this and one point related to the bounties especially when we are using the other chaining services that are so cool I love it but uh you must be sure that you are doing some onchain transaction for example if you use data feed but the data feed is only in the front end doesn't matter to to us so if you're using data feed but you are saving that information inside the smart content yes this is good for us so the transaction must be on chain to use a chain link okay let's go forward so this is me you will have this and let's go a bit forward I'm here to talk about CCAP so I really love CCP because of how the cross chain things that we can do and I do a a demonstration for you related to a nft emoji that it's based in the Bitcoin price and also I'm using data Feit to do this so this is like a almost a game because I have uh different nfts the nftg can be maintained uh from the same I build this on Mumbai but I'm using to Mint the nft from Fuji avalan Fuji another word so is this we can connect the words in this way and yes you have the other C code so I pass this uh so fast for you but this is the SM confits um and how can I do this let's go so here I have three confs for you and I like to show a bit of this for you uh so first con uh is my the nft itself and this nft is useful for you because I'm creating an SVG file an image directly in on inside my content so can be useful for you to understand how this is built and also I may uh I have here the SE chain the chain that I'm using all the information related to the chains and I'm updating the metadata itself it's inside my content so I me create a Json file inside my smart content so this is a different way to create a smart content and an NF because I'm not using something like ipfs I have everything on chain and okay uh I have this cross destination Minter this is a counter that you mint the nft for me and uh because of this I'm using the CCAP receiver if you are using CCAP you must have in your content a function called _ CCP receive and this function you execute any message that you receive from the SE chain on my case this message you be like the mint command from the other chain so this is the address of my nft and I'm calling the message that you be this at the end I have the the Min the sement this will be on Avalanche Fuji for now and here you can see that I'm using the halters of chain link to have this part and then uh I really uh using the mumai where I'm using the structure of chaining the message the evm message and here you can see the mint command so I sending this message this mint comment to the other chain to the other part of the word so is this uh I already deployed everything because it's like a bit impossible to do this is so fast and what I'm doing now this is the nftg I have some here in fact I have a lot I refresh let's see how many I have now uh okay you can see over there that at the end I have two uh both came me like from polygon we have one more here because I do a transaction just now so I'm going probably let's see I must be on Fuji now yes I am on Fuji I deployed everything for like 5 minutes ago and uh I am in the cruster cementer oh by the way I must pay fees I may pay Fe using the liak token but you can use the native token as well and I using the M by now so let's meet in the other chain confirming the transaction how can I know the status of my transaction I use this ccip Explorer to do this so let's see if my transaction is confirmed yes let's get the transaction ID go to the Explorer and see what's happened now and yes we have the SE finalized we must wait some time to have this to have the finality of this and then I can come back here and explain a bit more for you let's see how is my time now okay uh is this this is the oh h i I'd like to go over there but I must I must be here so let's try to do it this way like we have the SE part uh where I have the dep the user over there is my sear is much content I'm interacting with the hter offchain L the hter is interacting with the offchain part where we have the Dons and the validators zubing you talk more about the those later and then uh this how is sending that message that transaction to the other chain uh using the hter in the other chain and that hter the destination hter is sending this message to my application my destination ment who is interacting with my nft meaning a new nft so this is a high level architecture and uh probably you are thinking about security of this we have in fact more than one neor uh acting in this way because we have a his management Network that is having votes as well and having a consensus to be sure that we can Commit This to the other chain and don't have like aor in the chain and your trans transaction can disappear no this cannot happen because we are taking care of the security of this and I think is this let's see uh probably my transaction is not done yet uh and I must wait a bit more I'm waiting and in this time time um zubing you talk about uh functions for you so zubing it's your time now thanks thanks l so while we're waiting for ccip to do its magic and for the actual transfer to happen of the data across the of the the the two chains I'm going to present to you a slightly different concept right it's a slightly different product so we're just going to switch while that's running the background so I'm here to present you on channeling functions now how many of you know what an AWS Lambda is or Google function is right okay excellent let's start with that as a mental model right first let me introduce myself though my name is zuin prap I'm a developer relations engineer chain link um a recovering lawyer ex Google site etc etc this is the best job in the world I get to work with people like Soul such a pleasure right now for those of you who aren't familiar with chain link and I know there are a few few of you who who aren't um it's basically an oracle service but why is that important because it's not so much what it does but why it's important right as you know blockchains are deterministic systems They Don't Really access the external world because if they did they wouldn't get consensus across all the all the nodes in the blockchain and so what you need to interact with the rest of the world and with other Data Systems is you need an oracle service that sits in the middle like a middle layer right so that way you can move data on and off chain however you need a decentralized Oracle Network to make sure you don't have a single node that's a single point AFF failure and that's kind of what chain link offers a decentralized Oracle network not that Dawn but you know it's funny so the decentralized Oracle network is a series of noes that run offchain but preserve the cryptographic guarantees that we've come to know and love from the blockchain world so even though it's offchain it has the same concepts of consensus cryptographically verifiable data being put on an offchain and that's what chain link does right it it it produces a middleware so you get decentralization trust minimization scalability truth truth through cryptography and verifiability and you also get reliability responsiveness and cost Effectiveness because you're not doing a whole bunch of compute on chain you can move it offchain without losing any of the gap guarantees so there's also consensus protocol in Chen linkon and that's OCR okay so I'm I'm I'm running through all this just out of mindful for time now this brings us to chain link functions so going back to the AWS Lambda and Google Cloud functions sort of um metaphor in your head if you like we at chain link started to say well what if we could run absolutely any arbitrary code that you wrote any code okay and the execution of that code that you've supplied let's say in JavaScript is decentralized so you get decentralization of the execution of that JavaScript code and the result of that execution is is cryptographically verifiably verifiable through the chain link consensus protocol known as OCR right so you combine all these things and you get chaining functions right with which you can call any API anywhere in the world run compute on it that's much more gas effective than doing an onchain get consensus on the return result and have that posted back to your consumer smart contract right the con the smart contract that consumes channeling functions so why do we need that well we believe that the new generation of web 3 apps are going to be hybrid there's going to be a a critical onchain component and they're going to be have able to access traditional data infrastructures so that you can enrich the web three world with that data without losing a lot of the C you know the benefits of decentralization and Trust minimization right so big diagram just to tell you that that's all you need to worry about is this bit on the left this is all you need to worry about just put your smart contract up have a subscription and invoke your chain Ling functions everything else is done by the chain Ling decentralized Oracle Network and the technology we've produced right your workflow broadly is three steps write some custom JavaScript write your your chain link consumer contract right your your functions consumer contract into which your JavaScript your your API keys in encrypted form all of that will go in there your smart contract will then contact the Oracle Network and the decentralized execution will trigger and you get your result back in the consum smart contract that you control right so in terms of how to get started now those of you are going to do this in the hackathon obviously as you know there are bounties for both ccip and functions both Sol and I are going to be here for the next 3 days to answer any questions you have but to get you started take a look at the following right run- functions. apppp right this is a bunch of community generated examples of chain Ling functions take a look at them the basic concepts are all broken out and obviously you can go to docs. chain. link where all the all the formal documentation is but this is Community submitted examples right of people writing uh decentralized functions code you can also play with it a simulated uh execution environment for your JavaScript is provided in browser where you can do a kind of pre-run right you can debug and you can do a dry run of your your custom code in this supplier argument supplier secrets and it'll spit out the hex output and decode it for you so you can see what it would look like onchain and you can use the npm tool toolkit which is an npm package that you know I co-wrote with a couple of my colleagues and that that abstracts away a lot of the complexity and breaks it all down into steps and the documentation is pretty good if I may say so myself it's pretty thorough but we want feedback from you use these three or four things and you should be absolutely without any problem using functions it it reduces what used to take three three to four days you know spinning up your own node and all the rest of that to about 20 minutes hour work right and so you can connect to any API now I also did a deep dive at our chain link hackathon which by the way you can still participate in at the moment it's going on at the moment you can submit to both there's no problem from my point of VI um but you can also watch The Deep dive of the chaning functions um deep dive that I did on YouTube by scanning that QR code and going and taking a look at it right um these are some more resources sorry this is Souls I I'll give back to Soul oh so let me hear again uh you are at have the presentation but I can give you a minute to get if you uh was a bit late to get it and yes we have more resources for you in our documentation but uh what about my transaction let's see what's happen happened yes success yes I'm so happy when this happen always uh let's see what's happened remember that I yes and this is also updated because I have a new nft here just now and this nft should be one of this Reds and this is the eight probably this is the last uh yes uh yes the seven the four probably must be so recent let's see if it's this no I didn't refresh yet but it seems to refresh it but by the way uh let's come back here only to see how oh we have a lot of time yes so let's see what's happened because I don't know uh it's by pricey Can I Do by recent listed yes so one of this you'll be like the last of this probably this is the last yeah yes dat like was before and you can see that I mined this from uh like Fuji was my red chain uh blue was the seoa and purple was the polygon and you can see here uh that uh I did this in the details part like 7 minutes ago so it was here it was now uh and this this you can see the price in that moment the cers was Fuji you can see the same let's get for example one of the others to you understand this better like I did this yesterday I think I started this yesterday and if I go this you can see that it was another PR price it's came from sepolia and yes it was one day ago so they are real they are minted in different times different chains so this is really really amazing and uh just summarize this as well the presentation of a bit more do you need it how good of this yes I missing some phones over there let's wait a bit yes we have time and okay yes and uh we are we are right to share with you a lot of resources but especially related to CCP you can go to the documentation a lot of people ask me about the supported networks so you can see the supported networks directly on this link as well and uh you know that's a bit uh is slow here but you can see the test Nets especially here we are using the test Nets and here we have supp optimism Mumbai Fuji BNB and basy for now so this will be useful for you and also uh we only talk about message but what about to uh to transfer tokens because because the CCP also can transfer tokens and uh yes can be used like cabridge we have some tokens that is managed by chain link and then you can transfer this kind of tokens or you can create your own pool managed by you your application and then use this pool uh using chain link uh CCAP only to cross the tokens but if you're using for example the the tokens that we are providing to you to test here we have the link of the two kind of tokens because we imagine I have a token in one chain what can you do in the other chain uh in the first chain I me burning the token or I me locking the token I must do something to this token not be used in both chains in the same time uh this is the point so we have this token burning mint lock and mint you can use this in the second chain I must have my decision as well I minting the token the second chain in the destination chain or I already have this tokens over there and I unlock this token depends of your business but we have some tokens for you to use to have the the Sol oh yes okay oh I talk more than I need now this is the developer part for you uh so we have all the information here and I think we are done so see you around we are over there bye this than they do bye
Automatic transcript — names and jargon may be misspelled.