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

Loading player…

Polygon đź›  Create Evolving NFTs with On-Chain, Mutable Data - Steph Orpilla

ETHGlobalSun, Oct 9, 2022, 12:00 AM

Join Steph Orpilla of Polygon for a workshop titled "Create Evolving NFTs with On-Chain, Mutable Data". ETHGlobal hosted ETHMexico in Mexico City 🇲🇽 - our first IRL hackathon in LATAM in over four years. This year hackers had the chance to build the future of web3 with a chance to win over $150k+ in prizes from teams like WalletConnect, dYdX, AAVE Grants DAO, as well as experience talks from guest like Vitalik Buterin and Aya Miyaguchi! Thank you to the 580+ attendees from 27 countries who joined us for this unforgettable weekend of learning and hacking. For Mexico, 65% of hackers were from LATAM, and 46% were new to web3! Thank you for being a part of it! ❤️ After ETHMexico, we are heading straight into a full month of learning & building 🏗 Get ready for ETHOnline, our largest online event of the year! --------------------------------------------------- Follow us: https://twitter.com/ETHGlobal​ Check us out: https://ethglobal.co​m Email us at: hello@ethglobal.com

Transcript

[Applause] [Music] hi everyone welcome to uh this session it's called create evolving nfts on polygon uh but first i'm steph i'm a devrel engineer at polygon um you can also find me on twitter at oceans404 but the o is a zero it's kind of hard to read um but we're talking about evolving nfts i just wanted to throw this up because this is kind of my eighth global evolution the first time i was on the main stage was virtually on zoom and then in amsterdam so it's pretty cool to be back in mexico as a sponsor full circle okay so let's talk about nfts um and we'll just start with like fundamentals so nfts allow for the creation of non-fungible tokens for tracking ownership of different things so we've seen that as digital digital collectibles like the board ape yacht club collection but we've also seen physical properties being sold as nfts and then even assets with negative value like loans uh but this is just an erc 721 um token standard so you can see all the required functions and also events uh if you create an nft contract you'll probably um extend a contract like this and you'll have to have all of these functions and events as part of your nft this is my pfp it's a doodle but what is really important about it is the token uri so the image the name the description and all of the different attributes that describe this nft so you can see the face has a happy note the hair is long and purple the body is a white puffer and one of the things about nfts historically is that if they're used for collectibles like mydoodle it's pretty important that these images and also the metadata are immutable so that they don't change so that this stays a rare asset for different features that it has that the rest of the collection doesn't have so with collectibles it does make sense to have immutability but can you think of any other use cases where maybe immutable assets aren't as fun or they just don't fit the problem statement i thought of a few so the first one is in gaming if you have nfts or assets that level up or change the way they look based on different things that happen in the game another thing i thought about was a covid passport so i have this really annoying piece of paper i have to carry around and then every time i get a vaccine or a booster somebody like physically writes it into my passport which is pretty ridiculous i think that should be unchained so a digital passport is something that could be a cool evolving nft also baseball cards uh i'm from la so i watch the dodgers hopefully cody bellinger never leaves but if he does his baseball card team would change and this um baseball card wouldn't be relevant anymore and then this is just kind of a dig at board 8 yacht club because static nfts are boring but how are we going to build this so we're going to use polygon pos in tableland just to give you a quick refresher on polygon it's an ethereum scaling solution it's great because transactions are really fast they're low cost um we're also going carbon negative this year which i'm really excited about so nice and sustainable and then tableland which you might have heard about i don't think they're here so i'll just talk about it but tableland lets us write sql to create tables to store mutable nft metadata that is governed by immutable rules and the tableland data exists on both polygon and mumbai so whichever network you choose to deploy on you'll be able to do that and so um in this dapp that i created i made two different tables a main table and an attributes table so the main table has id name description and image and then the attributes table has all of the different trait types and values that you would see as part of an nft so this is an example of one that i made today i called it tequila nft my spanish has been pretty bad this trip but i can always say the word tequila so that's what we went with for this demo uh but just to go back to the doodle really quick you can see that the attributes are the same way where it's an array of different objects and each object has a trait type as well as a value cool so i created some drink nfts i had five different images that we can update and you can see that the glass goes down down down i actually sent these to some of my friends who who are in this room christina you have one kartik and jacob i also sent you drinks because i thought you deserved them uh but i'm gonna modify your nfts to drain your drinks and i'll show you how to do that which is pretty rude in the real world don't drink your friends drinks but we'll do it today so we're gonna mutate the image url and then we'll also mutate different attributes um two callouts for this the first one is just that uh the default for tableland is that you can only mutate data if you are the contract owner so if you've deployed it you can mutate it but you can override that behavior by adding something called a tableland controller which allows you to have like the owner of the nft mutate it if you were interested in that type of behavior and then the other call out for this demo is we're going to be manually updating the nft just like from the command line but you could do this automatically with chain link keepers or a different solution like that so let's get to the code i created a github repo for this um it's just under my github ocean's 404 it's called mutable nfts uh table landon polygon i'm pretty proud of the readme so take a look at that if you wanted to duplicate this or do it in your own projects um it just has the two intros and then building instructions in case you wanted to deploy this yourself you would just create a dot env file add three different api keys for our mumbai alchemy key polyscan and then your private key and then you just install and you could run this smart contract to create your own contract um where was i let me get into the code okay so the first thing that's pretty specific to my tequila nfts are that this custom metadata generation i'm just setting it it's a naive solution i don't have trait randomness for these nfts i have three different tequila types and two different drink names and they're being randomly added as attributes attribute values these are just the starter values um i'll show you how to update these values since that's kind of uh the interesting part of this demo but i just wanted to give you a sense of how we're creating the the metadata first so uh the first thing i did was just deployed that smart contract and i'll show you the poly scan of that so this is the smart contract and then each of the table land tables also has its own transaction and it's actually a little nft which is kind of cool i didn't know that but each of these main table and attributes table is minted as an nft that you also own as the contract creator so kind of fun okay so let's get to updating the metadata like i said i already deployed this uh but we're gonna run the update metadata function to change some of these values around so i created a big block so you can probably update these on your own but there's two different update lines that i was playing with today the first one is changing the image so the main table had that image property so i'm going to change the image to an empty uh tequila cup where id is zero so just to prove that we're actually doing this this is the nft it is full and we're going to change this image so that it's empty and it's an on-chain transaction okay so i have the image link here i am pinning it on ipfs and it's stored decentralized in storage but i'm just going to change this so that it has this new image and then i'll save this file and then i'll run the script to update metadata and we should see this image change on openc so just going into my terminal i'll clear that out so it's a little easier to see but it's just an npx hard hat run script update metadata and you can see the network is polygon mumbai so this is just doing a read of the different tables that we already have and it is updating that image and once it's updated we'll see the transaction hash and be able to look at that on polyscan cool oops so again back in the code we were just updating that main table with the new image where id equals zero and i really like tableland because you can write sql queries which is just super user friendly in my opinion so i'm just going to put in that hash transaction and you can see it was successful and if you look at the input you can actually see when you decode this happened on chains so oops so you can see that this image changed where id is zero and now if we go back to this nft i think we'll have to run a refresh on the metadata because openc is a little slow but in a minute we should see a completely new image that is an empty cup oh not yet all right empty cup okay so that worked for nobody has ever cheered for an empty drink before okay so that's how you would update an image but you can also do this for the actual metadata properties so right now the drink name is margarita and the tequila type is enjo somebody correct that print yes okay you look like you know your tequilas what is your favorite type of drink we're going to change this metadata tequila sunrise okay that's the orange juice one right no shade okay um so i'm going to change this value to a tequila sunrise i commented out that line above just so that we have it for easier reference but we're looking for trait type drink name and we're updating value to tequila sunrise where main id is zero because it's that first id so i'm gonna run update metadata one more time we'll get a new transaction hash and hopefully we'll see a tequila sunrise and i'm not super artistic but if you were and you wanted to play with svg data you could do fun things with pixel art to actually make it look like the drinks someday i'll get to that level of artistry so we're just back in polyscan looking for that new transaction it was successful 23 seconds ago again we'll decode that input data and we see tequila sunrise at id 0. so let's refresh the metadata one more time and we have an empty tequila sunrise [Applause] all right i'm just going to go back to my slides cool so yeah check out that repo um i hope it's relatively easy for you all to uh change values and stuff in case you wanted to create some mutable nfts this weekend but just wanted to go over the polygon prizes one more time we have four different prize categories for the following problem statements so public goods refi which is regenerative finance metaverse or gaming and then the best ux or user onboarding experience to your dap so really excited to see what you all create we'll probably give away two to three prizes in each of these categories and then here's some developer resources if you want to take a picture of that they're also all online so you should be able to find everything if you can't come complain to me because that's bad user experience cool and then this is our polygon devs twitter uh a lot of my teammates aren't here this weekend but they love to see what you're building so tweet at them and use the hashtag onpolygon so that we can amplify your work and then last but not least wag me i'm in the middle next to jordy this is an iconic photo because he is um like the creator of zk ebm and i'm not worthy to be standing next to him but fun photo all right thank you so much feel free to come up to me and ask any more questions or just chat tell me what you're building and yeah have a great weekend [Applause] you

Automatic transcript — names and jargon may be misspelled.