IPFS & Filecoin 🛠Not on IPFS? Not your NFT - Coding NFTs the right way with NFT.Storage
ETHGlobal·Sun, Oct 9, 2022, 12:00 AM
Join Alison Haire of IPFS & Filecoin for a workshop titled, "Not on IPFS? Not your NFT - Coding NFTs the right way with NFT.Storage." This workshop is part of ETHNewYork 2022, a three-day in person hackathon that will feature hackers, mentors, enthusiasts, sponsors and speakers who are all gathering in New York June 24-26, 2022 to talk about the future of money, finance, the web, ownership, the way software works and the way power is distributed. We're excited about a new frontier. ---------------------------------------------------- Follow us: https://twitter.com/ETHGlobal​ Check us out: https://ethglobal.co​m Email us at: hello@ethglobal.com
Transcript
[Applause] [Music] hello hi new york how are you going um good to see everyone here hopefully you're all in an empire state of mind um ready for this hackathon it's like packed out here so i'm super psyched to be here i'm ali i'm a far coin developer advocate um or i work at the falcone foundation so and yes the accent is australian for those of you wondering uh but tonight i want to give you a brief intro into ipfs and farcoin and then i'm going to dive into the mechanics of making an nft contract and why ipfs and filecoin are so necessary particularly if you're not storing that metadata on chain and why that sometimes gets really prohibitive as well so this is a little project i've made it's a multi-chain multi-contract personalized nft collection uh so just built on solidity contracts i've used both an erc 721 and an erc 1155 contract and i'll dive into why they're different a bit later and with a react front end and some dev tools around this so hard hat morales for node provision and specifically nft.storage to um store our nft metadata so firstly i just wanted to clear up some confusion that's maybe maybe out there around a few names you've probably heard floating around the web3 ecosystem and share how these fit together so protocol labs firstly is an open source research and development lab it's building protocols tools and services to improve the internet and we really believe in this concept at the moment actually we're running funding the common uh funding the commons here in new york as well in parallel with this so we're really aiming to build tools and services that help radically improve and drive breakthroughs in computing and like move humanity forward and for the common good as well so some really big goals there um two ipfs and filecoin are two of the projects that were originally incubated by protocol labs and they now operate as their own separate but complementary projects within the ecosystem are still sharing the same vision um but let's jump into firstly uh cue the star wars music here interplanetary file system uh so this isn't just a meme name though because it's a distributed peer-to-peer network for files and folders ipfs was designed to be able to work even when you're between planets so let's say you signed up for the mars colony program and you're now living happily on mars maybe it takes you an hour or so to request a file from earth that you need but if someone else on mars already has that file then you can then they can just serve that content to you instantly with ipfs so maybe you're thinking this is just a fancy name for a peer-to-peer protocol or network now uh but there's real gravity get it in what it does because ipfs is distributed by design it has no central authority servers it's designed to be offline first for resilience and it uses specifically a really unique and upgradable standard for addressing content and this is a unique part of ipfs because rather than using methods that we might be familiar with for storing and accessing content so location parts we go to the web we type in a http url and that location serves us up a piece of content from some specific centralized server um so this is called location addressing and we're never really sure what content we're gonna get for that location that we go to so uh with ipfs instead we generate a content id so each and i'll just jump to this one for a second so each piece of content actually has its own uh cryptographic uh hash function so it's like a unique fingerprint for each piece of content uh and this is kind of wild uh or at least it was to me when i first started looking into ipfs and it's because it's such a mind shift from the web to way of doing things that we're like really accustomed to at the moment and it's super elegant for its simplicity because this really opens up the web to fully massively distributed storage systems and that's important right you can always if you can always verify what content you're getting back you really don't have to care where that content comes from um so that's really like the key part of learning ipfs the fact that it's not just a peer-to-peer protocol but it also has this content addressing system so it makes the web work peer-to-peer and by the way um that's a bit weird my speaker notes have stopped anyway that's all right uh so ipfs is not just uh for uh web3 either so it also works with web2 it's a protocol not a blockchain so it's used in things like flickr is has been using it some of our amazing uh colleagues here in the web 3 are also using it so i know ballast is built on top of it live peers built on top of ipfs audios as well to name a few um so the problem with ipfs in the wild though is like you can run your own nodes but as soon as you shut your laptop that content that you've stored on your own node is no longer really retrievable by anyone else and let's be honest not everyone wants to run their own uh content nodes um the other way you can maybe ask someone else to store your content for you but unless they really like that data or they really like you for some reason or whatever it is um that content may become unretrievable after a while and we've all seen this with kind of torrent insistence where less popular piece of data just stop being retrievable or available basically so a third way to do it is you could pay a pinning service to pin that content on the net for you but if we start doing this we're kind of opening up to these centralization issues that we already have in the web today and we really kind of want to avoid centralizing um our data pinning services by using pinning so despite maybe you know what the really annoying anyway despite what the community uh you know the community's general altruism or wanting to do this uh you know eventually content can become like unretrievable so this is where filecoin comes into the system really so far coin is storage designed for web3 from the ground up it's a distributed storage network um it uses crypto economic uh market levels to incentivize the storage of data so it uses two main consensus mechanisms to do this the first is proof of replication this ensures that providers are actually storing your data and keeping it safe when you first upload it and the second one is proof of space time so all of our storage providers and there's like over 4 000 storage providers globally at the moment all of them put filecoin up as collateral and they have to prove daily that they're holding a subset of the data that you've uh asked for them to store and if they don't do that their file coin is flashed and because like running a data center is quite expensive plus the amount of file coin to do it is also expensive they we're really uh decentralizing having bad actors in the system as well so the second thing is that far coin runs on market deals um so if you store your if you want to store data on the network you can firstly decide how many storage providers you want to store that with for resilience and redundancy and then secondly you can decide how long you want that content to be stored so it's really your data and it's your choice you can decide if you want to store that for six months or you want to perpetually store it using something like smart contracts for 500 years and just like keep doing that so the too long didn't read basically is that ipfs and filecoin are great complements so ipfs is great for that content addressing verifiability of content coming from anywhere and for fast retrievable uh fast and flexible retrieval and far coin is really that persistence and verifiability of that uh data storage layer um but what's this got to do with nfts you might be wondering um well if we dig into the anatomy of an nft contract and this is the erc 721 standard the original uh nft contract and this is the open zeppelin one so you could build an erc 721 from scratch if you wanted to but most people i think would use this template it's been audited it's community tested this is probably where you'd start in developing an nft um so this is a contract from open zeppelin like i said it's been ordered and community tested and here's the api for it here's the basic functions that come with this erc 721 and here's an example straight off the open zeppelin website uh that shows this implementation of erc 721 in solidity uh the ethereum language um so this contract basically creates a grain item here um as an nft an erc 721 and the function that mints that nft or stores it on the blockchain is called a ward item in this uh in this scenario in this uh code here anyway so and it takes two parameters the first is the address of the player so i assume that's who they're awarding this nft to the player and the second one is a string and a token yuri what is this token yuri well it turns out that this token yuri is basically just a jason file it's an object that has a few descriptors of what this nft is and it's really what you'll view on the web as an nft so you can see here it's got a name a description an image and say some other attributes like strength or whatever you want to add to this game item for example now the problem with this contract is that this image has a location address it's got a https address and even open zeppelin itself says you'll notice that this items information is included in the metadata but that information isn't on chain so a game developer could change the underlying metadata changing the rules of the game um and there's been some famous examples of this happening because they're using location addressing rather than like ensuring immutability and non-fungibility of the nft with uh content addressing so one of them is this like a rugs contract uh here someone created a full nft line it's sold out uh it was it was really famous and then they swapped out all the token uries all the metadata for actual rugs it was a legit it was you know a rug pull basically so pretty funny that one uh you know in retrospect uh the other one was this f bubbles one i won't swear but uh they basically use their nft collection to then advertise their next nft collection so they change whatever this um bubble said to advertise their next collection which you know really if you're buying an nft you want it to be non-fungible or at least operate how you understood it to operate in the first place and this is where you can really come into trouble uh with you know http addressing in nfts so you need firstly if you're not storing your metadata on chain which let's be honest you can get very expensive especially if you're storing this on the ethereum main net um and you know particularly for large files as well if you want audio if you want video if you want 3d objects as part of your nfts which you may well want to do with um for example metaverses or gaming examples then you know this gets really prohibitively expensive to store on chain so secondly you want to keep a fixed address for that content that ensures immutability now you can code in like mutability your contracts and there's actually we've got a whole tutorial on how you would go about that in the right way as well but that's beside the point for now but we want to ensure that this non-fungible token stays non-fungible so that's where the ipfs content addressing protocol comes into its own with nfts so these cids on ipfs guarantees immutable content referencing and the third thing is you really need storage that's persistent and reliable you want these nfts to last forever right not just like the next five minutes and then never be retrievable again so this is where filecoin comes into play as the decentralized storage guarantees uh for that you know nft metadata luckily though you don't have to go around and like create the whole ipfs thing and then cr store it on like eight different storage providers and make storage deals with those storage providers instead we've created a public good called nft dot storage and this is designed for devs who want free multi-generational decentralized storage uh it firstly you are you know create this nft storage uh metadata it will create a cid ipfs cid for you it will then make deals with at least eight storage providers to store that far coin content and it will auto renew those deals in perpetuity the best thing about it is it's completely free it's a public good so there's no cost to using nft dot storage it's actually used by open c and magic eden as well we're storing about 45 million i think it is at current rates uh nfts on nft.storage so it's really like a standard it's not just great swag but it is that too um so project demo i'll see if i can hopefully change my screen which looks like that's not what i meant to do awesome uh so this is the project that i've kind of made uh you can see i can just type in my name and it's kind of a customized personalized nft now i'm doing this on the rinkby chain at the moment but it also deploys to polygon or binance chain and that's via morales so i'm using morales nodes to enable me to like deploy to multiple a compatible chains with this now at the moment it says it's saving nft metadata to nft.storage and i just want to show you the mechanism behind that as well if i can find it which hopefully i can all right yeah not that one not that one let's try this one so this is creating the nft metadata this is my function that creates the nft metadata with nft.storage it's just really as easy as like importing that mpm library that node library into my react con uh front end basically into my react front-end and i create the client the same way you do with anything with an api key and then i use a weight client.
store you can see here the json that is going to be my metadata so i've got a name i've got a description i've got an image and i'm just like encrypting that on my front end so i don't get any injections but it's just an ipfs image basically uh and then i'm you know storing whatever other attributes i want to with it so it's really as simple as calling a function like this uh to create your nft metadata and let me just go back to oops it looks like it's actually minting it's asking my wallet to mint i just want to go back here quickly because if i could have a look here i've actually created an ipfs image link i think my internet's a bit slow so my image isn't showing up but you can see here like it creates i don't know if you can actually see the url but it's got a https and then it's got a cid which is like this big long uh letters and numbers here and then it goes dot ipfs.nft.storage.link and slash the name of this image which hopefully will come up soon but but um so this is our gateway so ipfs by default doesn't actually work straight with http which makes sense right they're two different protocols so ipfs needs to go through a http gateway to be seen on regular web browsers now luckily for us browsers like brave and opera do this by default so i can just type in ipfs and then the cid and brave will automatically route that through a um http gateway for me but other browsers don't do this by default and that's where you'd need to add on this gateway for it so things like chrome wouldn't do that by default don't know why that's not coming up let's not worry about it so basically after i've created my nft metadata it will return an ipfs cid for me which i'm pretty sure it does let me just type in metadata instead there we go got too many console looks anyway so this is what gets returned from nft um nft.storage hopefully you can kind of see that so basically ipn ipnft a url and then that data that i stored with it so attributes description image and the name of my nft um so i'm taking that ipfs url basically and then i'm sending that because this is actually a json object which i can verify by putting this into brave browser as well which also may not come up there's an example from earlier that so that's that's that's what i did earlier like the cakes no anyway so this should come up there we go so this comes up as the json object here and i just typed that straight in ipfs and then they are cid into the brave browser and it automatically shows you the json object that i put into that that's kind of just an aside now if i do click mint that's what i will send as my ipfs uri to my contract sure so now i can click mint oh look there we go my image has finally showed up thank you it does work it's true uh so now my nft is minting and it's basically just calling that uh my nft function in the erc 721 contract or 1155 contract taking that ipfs uri and sending it through i think maybe i'm just about at time here so i won't linger too long on this you can actually go and are we still no what are we seeing up there it looks like sorry guys looks like my screens are showing the wrong thing so just try and fix that that's better all right so uh you can actually go and meet your own fnft um at new york sorry nft i've only got it on test.
net but you can go and meet your own or whatever chain you like um just go to f new york file coin nft on the bitly link there and you can go and mint your own you've got some test snap um what else have i got all right there are more dev tools than just storing nft metadata obviously to ipfs and filecoin some of the easy ones if you want to get to know ipfs you can install our ipfs desktop or ipfs companion for browsers and play around with ipfs and how it works that way we also have ipfs http and go client libraries so you can go and have a look at those um and use use them in your projects as well fleek hosting is another cool one so fleek actually deploys your your static websites on ipfs and then stores that to filecoin and it's as easy as using say netlify or versel which you might be used to in the web 2 world and taking your site from github and then deploying it through fleek instead which actually is on ipfs and filecoin so actually making your daps your decentralized apps more decentralized instead of using a centralized website uh sorry uh cicd you could use flake um so another cool project is web3.storage so this is for any content that isn't just nft metadata so files folders text uh whatever else you might want to archive and store uh web3 storage is the right place to go for that another one i'll mention is textile powergate so this is a bit more advanced it's a docker container wrapped around an ipfs and filecoin nodes and it gives you more granularity around how you want to access storage deals or access peer-to-peer which is another thing in our ecosystem or access ipfs uh they also have some experimental bridges to other chains as well um and the other thing they do have is something called threaddb so a lot of people come to web3 and they're looking for a relational database now that's not an easy thing to achieve in web3 in distributed storage but there are people working on it and one of those projects is thread db another one of those projects that's working on a relational database is orbit db so you can try that out uh if you want to get in the weeds and and work on something relational database have a go at orbit db or thread db there's also heaps more tools out there using ipfs or filecoin or making them easy for you to use i should say so ceramic uh he's also using ipfs and far coin and that's a decentralized identity based solution for social id portability um lighthouse.storage as well also makes it super easy to use ipfs and filecoin and another project in our ecosystem if you're looking for our random numbers is dram.love so check that out if you're looking for random numbers um so some further resources as well here's that guide to mutable nfts that i was talking about earlier so that's on nftschool.dev there's also more like really short tutorials that you can go through on product school and get an idea of how that works uh there's obviously the docs always look at the docs right and then our youtube channel as well and after this hackathon if you do submit a project you can go and apply for one of our grants if you want to keep building on your project that's probably some of our further resources get in touch of course all our get in touch things um be involved you're already involved because you're all here right so congratulations on that and i've also got finally just want to show you some project ideas so these are some of the uh cool projects that are actually building on ipfs and filecoin so i did mention live pier and audience earlier uh huddle i won if anyone's seen the like zoom like web 3 version though huddle ones also building on ipfs um and like i said open c is using nft.
storage there's a couple of cool projects at the top there that are from 8th amsterdam that well i really liked so detress they were creating a whole tetris game basically and saving each piece as an ipfs cid and then reconstructing that and making an nft out of that game so i felt like that was like a really clever use as well you know of things to do but there's so many more things you could do with this um so you could create a video streamer uh you could create a youtube rapper with ipfs which you know might be kind of current at the moment uh distributed metaverse there's heaps of project ideas and past winners on our hackathons.filecoin.io site so if you want to get some inspiration go and check out that site and otherwise uh thank you everyone appreciate your attention and i'll be around all weekend so if you want to ask us questions come by the booth [Applause]
Automatic transcript — names and jargon may be misspelled.