New Ethereum talks, every Monday. The week's conference uploads by event, in your inbox.

Loading player…

Build a Dynamic Asset Monitoring NFT by Solange Gueiros

Ethereum DenverMon, Oct 9, 2023, 12:00 AM

Want to create a dynamic NFT that automatically updates based on real-world data? In this presentation, learn how to create an SVG-based dynamic NFT that reacts to a digital asset’s price changes using Chainlink Price Feeds and Chainlink Automation. Solange Gueiros

Transcript

Welcome everybody. Um I know that it will be a a big challenger to do my talk now because the internet it's not the best thing in this moment but uh probably uh the initial idea is to do a hands-on session with you. Um what I do with you I pass all the material for you and I hope that the things that I already have loaded in my computer can work. Now let's let's do it. So this is me.

My name is Solenigos. I am developer advocate at Chain Link Labs. And um uh for me it's a big pleasure to be here at Denver and to talk in this stage. I started here in 2019. It's my fourth year in Denver and I was a hacker.

I I won a prize one of the years and this year I run I was the organizers of one of the organizers of the camp build and it was really amazing because I'm pretty sure that we on boarding a lot of new developers for this space. I'm so proud of this and this is the most is most important slide for you. If you cannot read the QR code, take a picture because you can do this later. We know that probably you you not be able to do this now. So take a picture and this is our topic is building a dynamic asset monitor NFT.

um you have the presentation. So all the other care codes that I show you, you can get in the presentation. So don't care about this. This is useful for you because we have a lot of good information uh especially for beginners and this can guide you uh wherever you would like to do. And it's supposed to us to go to a a pad uh uh that you create now.

Probably not. Let's see. If I can if I can do it. If not, it's not a problem. Oh, sorry.

Oh, what I did. Okay. So, I copy and I used to do this uh to you do the all the the workshop with me. Let's see if we can do this. No, probably not.

This is not a problem. You can check the the material later. Okay. So, uh to build a dynamic NFT, what's our requirements? Uh I'm doing this on Gly, but you can do in any uh any chain that you like to do, but you need to have the MetaMask wallet.

We are using remix. You need to have the uh the it in the the network that you are working and also the the link token. I put some faucets for you because I I I not try to do but it it's supposed to do this. So let's talk about dynamic NFTs. Um when I talk about dynam dynamic NFTs I mean talking about NFT that can react with the world and I used to say that uh I am a dynamic NFT because I may being older day by day.

uh I hope to not be fat but maybe I hope to be slim but the idea is that I am unique and but I am changing day by day in the same way any of you all of you are are unique so you are a dynamic NFT as well and this is this is the concept of a dynamic NFT and we can have rules or conditions to change it can be the timing like I told before uh scores or highlights or experience or the weather any uh anything can change for example I have another example of a dynamic NFT that it's a flower that is growing by the time it's changing by the time in the sock world cup I create a dynamic NFT where we we are trying to guess the who won the world cup and at the end it was updated with the winner. So all of these are dynamic NFTs. Today in our dynamic NFT we are using uh two chain link services. The data fit is that because my dynamic NFT here is supposed to react with the it pricing USD. So I can get the USD the it USD price using the data feed and then if the prices go up or down related to the last time that I got the price I change my NFT so my NFT can be h can be said can be nothing this is the idea I have icons in my NFT then what more I'm using ah I'm using automation because the idea here is not that I can uh I do this uh by myself and clicking some button or calling some fun function time to update this uh and this is so interesting.

Do you know that a smart content cannot call it itself like the smart content cannot manage the timing or cannot manage the conditions alone? uh the match content must be colored by another account. This another account can be a external account like your account my account can be a oracle or can be another smart content. In our case uh we are using automation that it's a chain link service to call the smart contract for us and check the condition. what my condition that I'd like to check if uh I use a timely basis.

So every minute I check the condition and if uh some change in my condition the INF the NFT you change as well. This is the code of the dynamic NFT. Uh we know that you cannot get the code now. Remember that you got the slide so you will have it. This is not a problem for you and I will show you this now.

This is the code. This is the remix. Oh, remix at is here. So, let's explain what I have in my code for you is good for you. Yes.

So, I'm importing some libraries from open zapping. This is the best way to create your NFT and especially pay attention in these two libraries. the string and base uh 64. Someone yesterday uh was uh was talking with me about a strings and how to deal with some arrays use this that this is the best way and also I'm only importing the aggregator interface from chain link to use to get the price and I didn't to told you but my NFT is a SVG icon so I'm building I made life inside my smart contract. I really love this.

Ah, and I'd like to tell you that this project was not created by me. Was created by Hishard. Hish is another developer advocate from our team. And this is so cool because we have different people creating projects and all of us are using this. And you can see this here.

You can see the icon. So if the price is going up, I'll be happy. If the price is going down, I'll be sad. Or if the price didn't change, okay, it's flat. This is the indicator.

Uh to be sure that even if the price didn't change, my NFT was updated. I create this uh I put some colors. So I can change the background color of my uh SVG image. And this only this I'm using this on gly I'm don't don't expect that this work now let's see let's uh cross fingers and uh I only explain what you need to do here uh here is the update SVG function where uh I can get the information and update the string uh important for you I'm building the SVG here how I'm doing this. Here we are.

I'm getting the the color that I'm using and change the color. I have six or seven colors, something like that. And if I am at the last, I go to the first. Then I'm getting the the here I'm getting the icon and for getting the icon I compare the price, the it price. How I'm comparing the price?

I save the last price. I get the price now and see if it is up or down. Stuff like that. So easy. And like I told you before, I can do this in a automatically way.

Let's try first manually to see if it's happen or better because I I did this yesterday night. I can see if it's working. This is my NFT. Uh I just update the metadata. Now you can see that yesterday like in the same time the price didn't change.

Let's see if from yesterday to now it changed because it was in automatically way it was being updated uh to you understand how I'm doing this here I created this function to uh automate this. So this is updating by timing. I ask to update by minute. Probably from yesterday until today I I'm running out of balance because I need to pay on link to do this. And it's interesting to you to understand how this works because when your function is executed, you need to pay gas for this.

It's normal. But here you are paying in link. You have a balance on link using link in your automation uh automation subscription and then uh this is converting you are paying in link and this is converting to paying it the gas this is the process and you can see that I did yesterday uh this was yesterday I don't know like midnight something like that I was doing is and uh it seems that updated uh are you not I open a new screen because maybe I I I don't like to to lose lost lose the other image. Let's see. You know that our internet so crazy and I'd like to update this Yes, maybe we have you have this updated in a few minutes and you can see here that it's supposed to be colored more times than yesterday.

Well, uh I have this being update. So, let's uh share one more care code with you. At at Chain Link Labs, we have some bounties. uh we have two different uh bounties. One is for use uh the chaining services in general like automation data feeds or VRF to generate random numbers and we have another special bount related to functions that it's a a new service that we launched yesterday.

So you are the first guys that can use it. And uh this is so cool because the the the idea of function is that you can use any code that you write on JavaScript and call any API and use this inside your smart content because h it's so hard to use external service inside a smart content because the smart content are deterministics. So we need to have the same uh we have the same information uh and doesn't matter what time you are calling this this information you must have this information on chain to call it so if you call a external API you can call this save the information inside a smart content and all the network can access this information and have it in the same time let's come back and see if I I have some luck here. No, not yet. And here not yet.

So I can maintain this a bit more for you related to the bouties. And do you have any questions related to chain link related to dynamic NFTTS? I got the mic here if anybody has any questions. We have one here. It's supposed to me to do this to code live with you to have you doing with me to use the internet but uh I need to improvise now this is not a problem.

So my question is about uh you know how you said last night uh you were updating uh every every second or every interval every minute. So we have to pay link tokens for every time that happens right? Yes. uh you are paying link tokens not to check the conditions but when your condition is true yes you are executing some function that you define it and this moment you are paying link for example today this example it's a chrome job a chrome job it's a job that we only define by time in my case I define to be executed minute by minute okay in this case every minute I'm paying for this. Okay.

I have another kind of uh execution that you can define a condition in your smart context and only when this condition is true you it executes some function. In this case you are paying only when uh the condition is true. And is there like a fixed amount of link we are paying every minute uh or does it depend on the network price? depends of the network, depends of the gas price because the concept of the gas price we have the like the uh the fixed part that is the amount of gas that you need to pay that function but also this is multiplied by the gas price that can be low can be higher for example uh today on gly was so high so it doesn't interact with the uh ethereum ethereum main uh network does it or it's just chain link Uh no because your your transaction is sent to the network. So yes is interacting with the network and uh you are paying on link but this is being converted to it to pay the guest.

Awesome. Do you have more questions? We only have a few short seconds left. Maybe you want to check if your your metadata loaded. Let's see.

Let's see again. Fingers crossed. Yes. Not yet. Let's see this.

Not yet. Okay. Uh well, I put my Thank you so much. I put my contacts again. Feel free to contact me if you need some help in your project in the hackathon.

I'm here to help you. So, call me and we have other developers advocates here. I have Zubing here with me. I have also Daniel over there that work at Chainlink Labs. And we are here to help you.

Thank you so much. All right, give it up.

Automatic transcript — names and jargon may be misspelled.