DappCon 2023: Connecting Smart Contracts to the Real World - Solange Gueiros

DappCon 2023 · September 2023 · 43:27

Chainlink Labs developer relations lead Solange Gueiros walks through how smart contracts connect to real-world data and systems, at DappCon 2023. Drawing on years of developer education work across Ethereum hackathons and community building in Brazil, she covers the oracle patterns that let on-chain applications react to off-chain events and external data feeds.

Speakers

Topics

From DappCon 2023, hosted by Dappcon Berlin.

Transcript

hello everyone welcome welcome to our Workshop I'm here to talk about chain link and especially about the cross chain protocol so this is our goal and um thank you so much for the dcom team for organizing this amazing event and to have me here this is me my name is Sol G you can call me so I am a developer Advocate at chaining clubs and I used to travel around the world to conference to talk about chain link and to teach developers and I really loves to teach and to bring

you new people to this uh web3 ecosystem environment and uh I I really en enjoy to teach the last uh link is my website I used to add my talks over there so you can see other talks and workshops and we are here let's go to this place first before I I talk anything and here you can put like your name and where are you from like I miss from Brazil and okay let's add this here to help you we are in this link

now and this is a collaborative pad we can write together we can delete everything so be careful but this is the the best place to to work together and uh I used to say that if you know how to copy and paste you can do my workshop because I copy and paste out the uh the code for you here all the instructions and you can do the same in your own computer so welcome Christopher and let's uh wait a bit more for the others and like I said before I you talk about the CCAP this is the cross chain

protocol communication by chain link and um when we talk about this I used to do three or four approach related to how can we do this like you can transfer tokens we can uh transfer m messages and when we talk about messages we can transfer commands and C functions and this is our goal today because my goal is to Mint an nft one chain and this NT will appear in another chain and I doing this only using remix so we have like a hard hard heart stter kit as well but

I'd like to do in the easy ways so we are not installing nothing our computer it's only uh using uh remix and we need to have some tokens I think the like the hardest part is to get the tokens uh and my goal is starting on Avalanche Fuji and finishing on eum seia so I send comments on Fuji a transaction Fuji and this is sent a transaction to a seia and our nft will appear on seia is this wow we have a look from it where

are you look oh nice one look and a lot of people from Germany as well and Georgie from Spain oh amazing Welcome to our fi and this is let's come back to my presentation a bit more and to understand a bit of the concepts how can we update nfts with blockchain oracles first of all remember that nfts representing something can be a punk a ticket a real estate uh apartment or badges or training carts and uh but even today the most part of

the NTS are uh estatic and the go and the future of the nfts are to be dynamic in this case I have an nft from lamelo uh the basketball player that is updating us H scores and when we talk about updating FTS you can Define your own rules to do this can be scores car here highlights a weather experience whatever uh and my goal I finishing a new workshop and the idea is like when we to have the same nft in two chains and you can for example using the

metadata to see where is activ where is not activ for example for today I'm only meeting the nft another another chain but the goal is to create a nft that can Lees in different chains and be dynamic in this way as well when we talk about oracles to update an nft it's important to know what's a Oracle a Oracle is a device uh or external resource that you can use in your own smart contract and you can talk about like temperature weather sports information financial information I have a lot even the the information from from

my watch I can use this as well and this is chain link when you talk about oracles uh we are all important chain link is not a blockchain chain link it's a a set of services that are deployed in different blockchains like this we have a network of nodes we used to say Adon decentralized Oracle Network for different services and we can have this services for data feits this is the most popular but also uh we have services to automate uh smart cont execution to generate rown numbers to C external apis that you can write code on

JavaScript and use this information inside the smart content and uh this is some examples of dynamic flow Dynamic nfts that I did before in workshops like to grow a flower uh to have uh this characters that can uh run can do something different today we are using this characters as well this is our nfts and this is another that I did before it's like uh SVG price feed uh imagine that if the price from one time to another is growing up I'm happy or if it's growing down I'm setad and we have different background

colors uh and out of this this is another Dynamic nft that that I code everything inside the smart contract so this is interesting how can you update this and this is our go today today how to meet an nft in one chain from another chain and we are using the CCAP interoperability protocol and before talk about ccip let's start with the requirements because like I said before this is the the most difficult part and I have uh here my requirements and uh I will copy and paste here to you to be

together and we must have this first of all uh I told you that we are starting on Avalanche fui so we need to add Fuji to metamask if you you go to chain list.org connect your our wallet and you can added it I can't because I probably already have it yes avalan f is here okay and the next step you must have it tokens on Avalanche Fuji this is not good now probably we can go directly to the chain link faet and this the same you are con

connecting your wallet and then here you can get the link token and the Fuji token here I can get 20 link tokens and 0.5 Avalanche Fuji tokens I need to do a login using Twitter okay if you have any problems I can send to you later okay another Point uh when I'm doing a cross chain transaction imagine that I must pay fees in the destination chain how can I pay this I may paying this in the

Cy blockchain and I can pay using the nativ token for example if I am here in Fuji I can pay using Fuji I can uh also pay using link and in the the future you can can pay using other tokens as well uh for us like to get fush is not so easy in this moment so I'm usually link to pay the fees because it's easy to get the link tokens now in testet and this is our goal you must have link token and uh avax fushi got this the other part I don't know what is the change say

if you want to okay and the link and also you must have uh some ITA this is most common so I hope you have it but if you don't have it uh do you need uh tokens if you need you must tell me your name uh which token and uh address and probably I try to send you

in a minute okay let's come back to our presentation and you are getting your tokens now so come back here when I talk about uh cross chain interoperability protocol what can I do I can transfer tokens this is the basic like a bridge but we have a mechanism with a bit more security uh you can send any message I used to send like a hello word hello Bing uh message from one chain to another but when I'm sending message what about a message that is a comment that is calling a function in the other

chain and I I we we are using this today and in this point when I can send commands and functions to the other chain I can program all token transfer for example and like this can unlock the feature of uh an internet of blockchains because you don't have limits in this way to interact between contracts and this is a bit of the Cross chain stock like wallet uh applic ations where can you use it um and also one important point that I need to tell you is related to the workflow and uh here we have a hisk management Network so we

have two different network of nodes one network is really monitoring one chain getting the the transactions in the outter and sending to another chain and there are another set of notes that are uh really monitoring this in a security perspective okay so we have both uh in some moments I come back here to talk about use cases but uh between this I need to wait some minutes to my transaction be confirmed so uh we can talk about this later let's go to the Practical part again so Felix in a few minutes I send

token for you okay first of all we are starting on the destination chain and this will be sepia so in sepolia I do two points now first I create an nft collection an nft smart contact and then I I create the destination smart contact okay so uh like I said before I have like my copy here to to tell you we are creating the chain link nft oh wow we are on remix okay don't forget that we are on remix

now let's go to remix so J are you doing metam mask and now I'm going to remix and first of all we remix remember to go to to the icon 5 environment Environ environment and uh injected provider let's do this heix 1 2 3 4 5 environment change this to injected provider metamask to be sure that your remix is

connected with your your wallet and approve this I also use to go to solid compiler and enable the AO compile it's faster to you to work in this way I conf for let's enable the out compile now we are going to Icon two file explorer and create our file so we are creating the chain link nt.

so and here we are what I have here uh you can copy the code between the beginning and end let's create it let's see if I have it here yes I have it so are you using my now and probably are you wait are you change the name of nft this is the chain [Music] link. so let's update this for you as well L where is the constructure constructure oh the last time that I did

this was in so we are on that now so is this this is our nft and yes you must trust in my code now but probably I cop something that more than I need it let's go from here until here and let's deploy the nfg this is this is only the nft and if you are with me please add

here your name and your nfg address like let's get mine I think I am in the wrong Network let's see yes I told you to go to seala but I won't I didn't let's go to seia and now I can deploy and so this is the wrong yes let's get to this and where is the people that need

uh Felix let's s to you I think this is good and mouth and the Muhammad and to be sh how was to create my

contract how much I spent oh it's good so with this you can create your contract now I have my chain l inft oh JY congratulations that you are doing with me and this this so we have the nft the destination chain now when we send um the mint command to the destination chain we must have a contract to receive disc comat and to Mint the nft so this is will be our destination Min before that if you'd like to to see your nft maybe we can see before

if I go to open C this is the chain link.com I already minted the one NF my collection during the the deploy and to understand better what's my nftg I'm only using open zapping the base to create an NF I have these four images for characters that I show you before in the constructure I Define the name of our collection and I meant the first nft and like I have four four nfts and I me alternating the characters one by one

uh this is the next character you be like 1 2 3 0 1 2 3 0 okay and this only this I have here the safe mint the mint function and it's simple okay and this is my nftg this is my collection Next Step let's create the destination M this is a contract that will receive the mint com let's get this for

you and the same begin end and here is the code and let's see if I have this done here destination mean that I have it I explain what I have here so here I'm using the chain CCP I'm importing the CCP receiver this is importing the uh the structures to the hter because uh the process is uh we have a hter in the cersi blockchain that receive our transaction we have another hter in the destination blockchain that is receiving

the transaction from the cersi blockchain and following to our concrete so we must have the CCP receiver also we have the client library with all the structures that we need and I have the nft so here um when we have the hter we must uh in each chain the hter has an address how can I say this how can I discover this because I lock at this in my concrete but when we need to get the halters you go to the supported networks and for example his is seia his is the hter let's add the support networks for

you if you need it okay oh here and here we are in the constructure I'm initializing the nfg with the address of the nft collection that I just created and I must have a function with this name CCP receive because the outter is looking for this function in my contract when he found this function he's sending the message to my contract and what can be the message in my case the message is a comment so I'm using

the message with the address of my nft I me calling the like the message the information it means that I me using the mint function here I send the mint function from the other chain is this and I create a test mint only to be sure that is okay uh I think I didn't create yet so let's uh deploy the destination Min I need to get the address of my nfg ADD here in the parameter of the destination winter and the play confirm and if you are with

me could you add here your name and destination M address maybe I can try to interact with you later is this this is mine at least mine I add for you and you can use mine as well if you like it so this is done the destination part is good let's go to the search part now CI blockchain you be aalan Fuji so you must select this metamask let's

go and this is the cing okay I add this for you so now you must create this cin do s let's put this here here we are remember that you must go to avalanche now I am on Avalanche okay uh C cementer I have it here and here you can see that also I'm

importing in the cersi blockchain the cers concrete I'm importing a inter an interface to the hter is this the client of the ccip as well and because I'm paying using link I must have the link token interface uh I have I managing some parts here like to see if I have enough link to pay the transaction uh if I at the end you like to withdraw the tokens that I added in this case the link token uh and so I managing

this I Define the cersi hter the link token because I miss sending to another chain I must know the the code of the destination chain I can get all of this here in the documentation the chain selector is here for example [Music] and is this the destination MN it's my contract that I already deployed on SE in the constructure uh I created this in a way that only the owner can send this message but you can do to any person do this here is the hter in Fuji for

example let's see here if I go to Fuji here is the hter address that I'm using it's here and the link token as well I got in the same place link token and the destination chain selector it's seia so I meting on seia I creating a structure that is a message evm to any chain message I must say what is the receiver what's the address of the receiver in the other chain what's my message in

this case my message is the the command the function mint to the address if I is sending token I here I can Define the token amounts and in my Cas I'm increasing the gas limit to be sure that I don't have problems in the destination chain here you can see that okay I am on Fuji now I must know uh what is the fees in sepolia and this is like the hardest part sometimes I already got a horse livey because I send the transaction and the if he increasing that moment what I sent it was not enough in this case you can manual manually uh executed the

transaction in the blockchain destination blockchain I can say you later but uh you must be careful because uh now we can get fees but this can change during the the process okay and this is we are sending a message to the destination chain and the message is the main link command here I have the link balance and to withdraw the link it's only the owner that can get the link back is this let's deploy this now I must use the destination M address here copy

confirm and could you add your name and S address you are not with me I'm sad if you are doing so let's get mine s here we are this is my address okay Next Step hey Mount thank you you are with me and uh now I know I must fun the cement remember that we are using the link token so I must send the link to my

contract I can do this on metamask I send 10 links to my Contra let's go to metamask uh or if you don't have the link token appear here let's so it this maybe you don't have it hey J is doing as well uh how can I get add the link token go um link token contracts it's a bit slow now and I am on Fuji you have it uh the edit wallet button here

okay if you need it let's see if I have it and get my address again here I have it send 10 links oh congrats Georgie and Felix that are doing with me and here we are let's see if I have the tokens here now

yes so everything is done I can me on seia now and the important part now is to have your transaction ID Let's Do It Remix cinter mint on seia confirm and I you get my transaction ID copy transaction [Music] ID and I using my transaction ID in this ccip

Explorer let's search my transaction ID here and you can see that the search was finalize it but when we talk about blockchains uh we must have uh the fin status in the transaction it means that we must wait more blocks to be sure that uh cannot have a he org in the in the chain anymore and to be sure that your transaction cannot be reverted because of this we used to wait more blocks more time and this is the case now we must wait some minutes to do

this and I'm used to start on Fuji because from Fuji to seia I used to wait like four minutes but if I start on seia Chi is 20 minutes uh so exactly because the timeing block is different in this case we are waiting it's committed now you just saw that change the status I still must wait but when I when I waiting while I waiting let's talk a bit more use cases some ideas to you related to CCAP cross chain collateral imagine that you can have collateral in one chain and do

uh using L borrow whatever in another chain and you are locking one chain using another chain uh another Point imagine that sometimes uh it's so expensive to do computation simply computation what about to do this computation in a low cost chain and only bring the result to your a main contract in another chain you can also have a optimization you can have some profit between chains and uh thinking about this you can have a different kind of applications like I'm using nfts and you can have whatever you like imagine

including a d that must vote and uh a lot of times I saw D deploying the structure in another shipper blockchain they started on AUM and then it was so expensive to vote something on AUM and let's do it in gnosis for example imagine that you can do this using a cross chain application and oh I have one more that I like to show you this is the basic architecture and workflow that we are doing we are the user we deployed the sender contract and here we Define what is the message and where is going

destination Block Chain here we have the hter that's receiving this and outside we have the dawn the decentralized Oracle Network that's monitoring this and send the transaction to the halter in the order in the destination blockchain and I already I am in the destination blockchain so I don't have the destination chain anymore but I have the message to send to my receiver contract in our case uh I must have the CC receive uh function like I said before the underscore CCP receive but if I'm sending tokens for example I can

send the directive to my wallet and I don't need to have this part and this is a CCP message can be uh only arbitrary messaging or a comment or a token transfer this is a bit a complex structure so when we talking especially about tokens we used to have some mechanism in the token part uh if you are the owner or the manager of the token you can decide for example that you'd like to burn the token one chain and mint in another chain but when we are not chain link is managing some tokens we have some test

tokens now and we can like lock the token in the first chain and in the second chain unlock or mint in the second chain so you have like the the main token and uh like uh almost a rapid from that token in another chain and you can manage this as well and so important that like I said before we have another network of notes that is monitoring our transaction to be sure that we don't have hacks how we have a lot this year in Brides H and oh this can be good for you

before I come back uh like I said before I have this in a a uh like a hard hat package as well so if like to build more complex stuff is better to use hard hat than remix and uh this this is another important uh care code for you this is the presentation so all the links are here and probably when I come back to the CCP Explorer my transaction is done let's

see one more minute okay so let's see what's happened success yes wow it's success so if I come back to my nft collection I should have two nfts here now yes I have two one was was minted from Fuji so do you have any question related to CCP or do you need tokens do you need help uh wait a minute we have a mic because we have a people

[Music] online hi uh can you elaborate on the risk management uh part yes there are another set of nodes that these nodes cannot commit transactions they cannot see uh they they are monitoring this so let's come back to my presentation because I have this in a uh in a detail arud and workflow here we are when I have the the how is sending talking something like that the hisk management network is writing in a smart content this is like another content that's

committing the transaction so I can uh write here and this content is monitoring all the transactions here as well uh using events to help this in this way before the transaction go from the CI blockchain and be in the destination uh blockchain this network is also monitoring the amount of blocks that we need to wait and monitoring and be sure that the transaction will not be here before that and also we have a structure that we are are committing and saving the transactions in a smart cont that you can you can see uh where is

this so all of these are transactions on blockchain and this is transparent and you can see what's happened to be sure that we don't have anyone cannot manipulate this okay also if you need more uh more information related to this uh I really you can go to the resources uh and not the resources anymore you can go to the acud and building and concepts of this okay and let's see Mount what is your transaction let's see what's happen with here oh probably

what I did wrong no I I add his name together okay m is done as well yes so good and to finalize uh also next week if you are from Berling we have an another boot camp like it will be two days Monday and Tuesday 4 hours per day where I uh teach you how to use the AUD the chaining services so if you are around here you are

welcome and are you starting from zero in this boot camp are you create earc P tokens and FTS and a token shop and automated contracts and create a raffle I really create a lot of things is that available uh remotely as well only only in person for the remote people we have you can check our website as well or even my website I have more online and this this these are my conts again feel free to contact me and I hope to see you around the

conference and thank you so much and also uh when also if you need to talk more I have a joy over there Joy H she's a community manager from chaining as well she lives in Berlin so feel free to talk with her as well and we are here to help you thank you