Building NFTs with 🏗scaffold-eth - 0xPoland S01E05
ETH Warsaw·Thu, Oct 7, 2021, 12:00 AM
👨‍🏫 Austin Griffith, Ethereum Foundation: Building NFTs with 🏗scaffold-eth #0xPoland​​ is an initiative to build an active community of blockchain developers. If you want to improve your coding skills, make sure to join our monthly meetups, workshops and a hackathon in May 2020! ➡️ Sign up for our events here: https://www.meetup.com/0xpoland​​ ➡️ Follow us on Twitter: https://twitter.com/0xpoland
Transcript
so welcome austin so the stage is yours so thank you maybe just one sentence as i promised now zero theory 100 practice live coding from austin off you go here we go i i might i might there might be a tiny bit of theory like two percent we'll throw that in here just just to give some context uh so thank you merrick for having me hello xerox poland thank you mp that was a great talk i love thinking about all the creators that are going to be empowered by this technology and the thing that i want to kind of highlight as i go through coding this is just how any old developer and artist type can just grab something off the shelf and really deploy something really neat on ethereum and that's kind of what i'm going to dive into here so here we go i think what is it 10 30 we'll go for maybe 30 minutes maybe a little bit longer we'll see we'll see how we go maybe break a minute break it up into 10 minute blocks so first of all a quick intro uh i'm austin griffith you can hit me up at austingriffith.com or austingriffith on the tweeps so hit me up if you have questions my dms are open i'm always looking for great developers and to help great developers get onboarded into ethereum also this is an nft talk so if you're a weird artist developer or whatever reach out hit me up in the dms and let's figure out how to get you building on ethereum so uh let's uh first of all i want to kind of set this as kind of the uh kind of the the base the the layer the the foundation right if you need help go to ethereum.org there's so much good content here where you can learn more and find out how it works find out how to build uh but particularly we're talking developers today right and uh you there's tons of tutorials too like documentation look at all this documentation i bet you didn't think that was on there look at all this stuff ethereum.org has really evolved and really matured and became a great hub for ethereum and ethereum developers in particular so learning to code you could grab remix uh off the shelf and kind of code something up or you can dive into each build and play around and then setting up a local environment there's a lot of great options here too and one that's not here uh but merrick has just recently released is used dap and that's another great one uh to check out we'll we'll dive into scaffold eth in a second but i want to pull back just a little bit and talk about each build uh if if you're doing any tinkering on ethereum or you're looking to earn or learn the kind of the foundational knowledge there's there's sort of you know hash functions key pairs transactions i go through with each build and kind of wire these things up live on on youtube and kind of talk through distributed leisure byzantine generals kind of getting to this problem of consensus and how it's solved by proof of work and then into blockchain transactions and finally smart contracts all right so what what is eat build so eat build is uh not only kind of like this educational framework but also this this kind of like node editing library like grab a hold of this let me zoom in a little bit i can grab a hold of this or i can i can bring in say a hash function right and we can hash hello world and we see it show up on the other side right so you kind of have these tools and you also have a lot of web3 tools like even the transaction pool if you want but this is just a simple gas calculator i built and all these little uh dashboards are great i keep these on my desktop and i pull them up every once in a while we'll come back and we'll look at this but you can put in how much gas you're going to use and it's going to go get the gas price for the fast speed it's going to get the price of ethereum for you it's going to multiply everything out and tell you you know at 21 000 you're gonna spend five dollars so to send a million dollars on ethereum right now it's going to cost you five dollars to get that to go through quickly uh here's another one i use so this is this one is looking at the the most recent block and then also the highest prices in the transaction pool the mimpool and then it's also following my address and so it lets me know like where i am in terms of getting that transaction executed another another handy thing to use eth build for okay uh i'm gonna leave this we might come back to this but it uses so much cpu i'm just gonna throw it to the side okay now we're ready to start at least building a depth and then soon we will get into nfts uh the next thing i want to introduce is scaffold ease so scaffold eats is a freestanding decentralized app it's got the smart contract back end it's got a react front end and it's got a bunch of handy scripts that i've i've written and the community is written to kind of wire those things together and give you the experience of i have a dap it's up it's ready to go i could deploy to production right now if i wanted to what i want to do is learn how this all works by making some small changes and tinkering and kind of learning solidity learning dap building learning the mental model just understanding kind of what what this what this elephant is right okay so uh let's let's just go for uh a quick spin up here so so i i'm going to bring up what let's just let me start with just scaffolding so if you even google scaffold eth right you're going to land here and it'll take you to the repo and there's a quick start and what we'll do is we'll clone it down we'll cd in and we'll do a yarn install that takes a while and i've done that kind of with three different repos down down the line uh but from there we'll do a yarn start and that will bring up this dev uh this react dev server then we'll cbn and we'll yarn chain and that will bring up your hard hat node so hard hat is the the kind of back end here it is our local blockchain and it has a bunch of accounts that are loaded up with money and it also has a nice quick chain uh for us to make transactions against but uh it's it's built for introspection it's gonna give us stack traces it's gonna let us do things like console log right in our smart contract so so let's just run through a quick little setup of scaffolding before we we move on to you know upgrading to building nfcs so the last thing we do have our environment in our chain is we'll do a yarn deploy and that's going to compile this this sort of uh template smart contract it's going to deploy it to our local chain and it's going to inject it into our front end and our front end will will reload and what you get here is this nice scaffolding that's that basically reads what your smart contract has and then gives you an interface for it so it's kind of like the ether scan read write contract stuff but locally with your own contracts and and it will it will change let's see let's change this to dabs right well if it's already says unstoppable apps so that's basically gaps anyways let's go just make a small change to our smart contract we made one little change here now our contract address is going to change we're going to get a new contract and hopefully this purpose will change here there we go okay so we're kind of we're in the dev loop now we're able to make changes to our smart contract we're able to see them in our app and we're able to kind of like start testing assumptions and trying things out so uh if we wanted to interact with our contract we are going to need gas and there's a nice uh button up here which kind of leads me to the next talk which is like let's talk about accounts but first let me see if i can set the purpose here to hello zero x poland let's go there we go all right and let's try doing a send there we go so we crafted a transaction we sent it to our smart contract and we updated the the purpose in our smart contract okay so before we get into that too far let's let's talk accounts real quick so with scaffold eth when you land so i'm going to open up an incognito window and i'm going to go to localhost 3000 what we'll see is we get a different address see how this is like purple guy purple purple cacd and this is like b2 a9 okay so if we look at these two we can see that this uh cacd doesn't have any money yet and we can see that uh d2a9 has 20. so let's let's copy their address and let's go over to a wallet and let's paste it in and let's send them five uh dollars in ethereum and i bet we pay quite a bit and guess well we are we saw it uh back on that gas calculator it was about five dollars we pay in gas also so so there we go so now we've got accounts we're able to send money back and forth between those accounts and if you see that let's just dive into that again kind of every time you're going to build an app you're going to say i need an address input right and it would be super dope if i could type in vitalik.
e and it would do ens resolution for me right it's really nice when i can copy this by just clicking on it and i can paste it oh come back here i can paste it in here and i can see that little blocky preview if i copy this guy's address it should turn purple right so the the app itself has a bunch of components and hooks that are going to help you with your front end so you can focus on what changes do i need to make to this smart contract and what changes do i need to kind of how do i wire that up in my front end and all the other stuff is kind of all taken care of for you and and you can iterate on what's important so there we go uh we've got our second player i'm going to close him out we're able to talk to our smart contract uh if we go look at our smart contract it's just keeping track of some purpose uh a lot of times i like to do an underflow i'm not even really going to do that demonstration here ah the console lock let's do this let's set the purpose one more time um hi hi hi and let's hit send what i want to go c is right over here over here on in our biddler term in our hardhat terminal it used to be called biddler in our hardhat terminal we've got a console log that says you know this this address d2a9 set the purpose to high high high so if you're in there and you're building some uh you know intricate piece of solidity code and you you're doing some math and somehow it's a rounding and you're losing things and you wish you had some introspection into what was going on with with your smart contract there you go you can kind of get in here kind of you know it's a little bit caveman debugging still this this is some heady state-of-the-art stuff though you know this is tough stuff but once you get in here these console logs are going to help you out a lot so so you can with scaffold eath with hard hat kind of have that introspection into what the heck is going on and when something weird is going on you can always get in there and kind of get a get a console log going and figure out what's going on okay i i think we've basically covered uh the most like the the premise of scaffold eth uh we've talked about the back end let's let's look at the front end actually real real real super quick uh if you go to example ui i've created an example and and there's events here there are these buttons here and then if we go look at that over in the the app you can see kind of here's the button to set the purpose right we're tracking the purpose uh with a state variable and then we're using this kind of transaction helper here where we go to our right contracts because that has a signer we go to your contract and we say set purpose and we pass it in right and and then so over here i can say hi and hit set purpose and there we go we basically created that a front end for that smart contract in in this little box right here right now we could ship that to production uh by changing our hard hat network and doing a yarn generate and a yarn deploy uh but let's not worry about pushing to production we've let's let's say we've we've got the the basics of scaffold eve down and now yep we want to move on to nfts real quick but let me show you just some examples of some things that are built with scaffolding so the first thing so the fact that you can pull all this stuff off the shelf we're seeing a lot of people use this for a lot of hackathons uh one thing that we built is uh nifty ink so if you go to nifty.ink you can see this really cool nft platform and if you happen to look kind of closely you'll see that oh that's that's using scaffolding i can tell that that is the same style as scalp elite right and and same thing right i could pull this wallet and i can say hey let's go to vitalik.e and then there we go uh so so this is an nft platform built with scaffold eath uh it's it's on a side chain that upgrades to ethereum it has some really neat scalability properties but that is a talk for another day another fun uh little build recently is the punk wallet so i created this burner wallet like experience where you can kind of select whatever network you want and your identity is a crypto punk so uh i'm even going to take a gamble here and i'm going to put my my punk wallet on localhost there we go it did work it even gives me the ability to grab funds so you can you can technically just spin up a hard hat node or any local ganache any you know any rpc and you can open up a punk wallet and have it operate on your local host and have multiple identities let's see if i go pump wallet here we're going to have a different punk wallet there we go and even log out of my meta mask there we go there's a random cool so if i can copy this punk's address and paste it in here and we see oh yeah that is definitely that that dude there and then we do you know two dollars and we hit send and hopefully locally this guy picks up let's see if i go to localhost there we go we've got two dollars on localhost so fun fun little way to kind of show off how to send around ethereum and also just kind of something quick built with scaffold eath i kind of pulled pulled the master branch off the shelf and just quickly hacked that together and hopefully you can do the same thing so we've we've got a base we've got a base level of hey scaffolding is adapt you can use it to build your back end and your front end you can use it to deploy dabs quickly uh what can i use that for and that will take us to uh the simple nft example so here we go we this is this is a scaffold eath branch that's going to take us through deploying nfts let me let me make sure we got everything stopped over here no local chain okay so i'm going to fire up a yarn install and a yarn start just following these in instructions exactly i don't i don't even know i'm gonna i'm gonna paste this into my chat i don't know if it'll make it to you guys uh oh here we go here we go watch this watch this if you want the link to this repo uh uh i was gonna put it into each build too much work too much work i'm not doing it i'll i'll set i'll send it uh we'll send in the show notes or something but here here is the simple nft example really you could just google for scaffolding go to the branches type in simple you're gonna find simple nft right there okay so starting here we've done a yarn install and a yarn start now let's do a yarn chain and we'll bring up that local hard hat node okay and notice there's our there's all of our accounts that are full and then let's see let's follow the instructions here exactly it tells us to do a yarn deploy all right let's do it so again this is going to be a freestanding nft app and we'll be able to kind of tweak it to to make the changes we want but it kind of works out of the box and then lets us make the the changes we need any old hacker any old artist should be able to do a get clone of this thing and follow these instructions and have your your nft gallery up and be able to kind of uh kind of iterate from there okay let's see what we have here there we go very familiar right we've got a scaffold flashing all over the place i'm sorry got a scaffold eth app here uh let's see what it tells us to do okay open up localhost 3000 we've got it doesn't look like we have any collectibles yet or transfers looks like we could go to the faucet and get some funds okay so now we've got some some local funds for gas all right what's next okay so we need to edit the mint script so in hard hat scripts there's your usual deploy script but with this with this uh build in particular there is this mint script so in the mint script it looks like we got to pick our front end address so i'm going to grab this address and hit paste so i think that's what the instructions have us do just bring in your your front end address and paste it there and then we're ready to run the mint so what this is going to do is it's going to take some uh nfts that i've set up already and we'll dive into what this really means in a second but it's going to take some already ready to go uh paintings of mine and we're going to mint them locally the the goal being to set you up for uh uh kind of having something that you can iterate on so let's uh let's do it let's do this yarn mint let's let's let's see what happens here so my assumption is we've already deployed our contract and the yarn mint is going to get in here there we go so we're uploading to ipfs and then we're minting these paintings there we go we got a fish what's next what's next oh yeah there we go flamingo godzilla okay so here are our nfts uh they've already been minted let's see what is next there we go yep we do see them it is working okay now it tells us to open up an incognito window and let's go to localhost 3000 and what do you think it's going to give us a burner wallet it's going to give us a new address right this is 569f this one is d2 and then what we want to do this guy doesn't even have any gas yet let me just copy his address and let's let's send him let's send him this zebra right so we paste that in we can do a quick visual inspection to make sure yeah that is the address and transfer and hopefully boom there we go so we moved it from one account to the other right so so we've kind of there's this front end that's already crafted for you to let you transfer these nfts so so you can deploy an nft contract you can mint these nfts and then you can kind of transfer them around and that's that's kind of the basic of basics of this ui but what we want to do is get in here let's see got that we got that we sent it around okay let's see it wants us to okay this is actually if we're going to deploy it we're not going to deploy it live i'll probably leave that and let's get in and start looking around uh yep mint okay cool lots of fun stuff here side quests it'll help you get your nfts on to open c it'll help you do some other things but let's get in and like look at this nft and look at some coding really there hasn't been a lot of live coding it's been a lot of live looking here but uh that's that's one of the great parts of ethereum is there's a ton of composability what we've done here is we've grabbed open zeppelin's erc 721 contract so if we go here and paste this in we should be able to find their example so so first of all if you go to their github and you go to their contracts this is this is where a ton of stuff uh the the ethereum space as a whole inherits a lot of stuff from these open zeppelin contracts but if we go to contracts and we go to token and we go to erc 721 here we go so here are the the here is the erc 721 uh token standard from uh a token contract from open zeppelin you can see there's there's a lot of stuff here there's there's you know a lot has changed since you know 2018 when this came out but uh they've they've added a lot of like introspection and and some other things that cost a little bit more gas ways to kind of iterate through uh but this this is an nft so if we think of the code of an erc20 it's it's more like uh uh a mapping of some accounts some account to some balance so each individual account address has some balance and that balance is just a number and it increases decreases right so to transfer this fungible erc 20 you know alice sends 10 to bob and bob's balance goes up by 10 and alice alice's balance goes down by 10 with an nft it's a little bit different here here we are we're talking we're talking uh we're doing less live coding and more theory but an nft is a little different it's the other way around the token has an owner so each token is an individual unique item and it has some individual unique metadata but it also has a reference to an owner and when you transfer that token around you're just changing who the owner is so erc20 you're kind of adding and removing balances right erc721 you have these each individual tokens that are unique and each of them has an owner and you're sending them around one at a time you're minting them one at a time okay cool and if we get in here we can see the code and see how that works uh this token uri is the magic piece so the this this unique method data that we're talking about is this token uri and inside of this token is just a string that that is you know what what makes this specific token worth owning what is the thing that you are owning when you have this you basically have this like record of owning it but what you're owning is this string right here and this string usually goes uh to to an ipfs manifest so usually you go out to and let's let's just go look at that here so in in my mint script we have this this buffalo right and here is that manifest and here's what it looks like if we were to put it into ipfs so ipfs is this storage layer that's peer-to-peer uh eventually i think there's some some mechanisms to incentivize it but within uh ipfs we can do an upload so what happened here is we took all this information and we put it out on ipfs and what we get back is the hash or the fingerprint of that data and it's content addressable so if anything changes here let's let's go ahead and say this is blue and hit save now watch this hash right here when i upload this again the hash is going to change yep okay so now we have a different hash two six and if i upload that over and over again i'm always gonna get that same hash so when you when you create your nfts you sort of figure out what the manifest of this nft is and you put that out on ipfs it's saying here's where you go to get the image here's what the name of this is even attributes that you want to show up on openc and other platforms you upload that to ipfs and you get your hash back and then when we go back to our contract we put that hash right in here so that's that oh no that's the token id we put the hash right in here that is our uh our token uri it it returns this this string memory token uri when you ask for it and then i give the back that it's mavis okay so we've we've got our buffalo uploaded and changed uh i think what we want to do now is maybe add uh this so in this case what we what we do is we mint them so we deploy the contract and let's let's actually do uh yarn deploy again and look at what that how big that thing is there we go so we deployed oh it was yeah point one each is what that cost so like 200 is that right let's see what i don't even know what heath is at right now but if we do 0.1016 something like that yeah what 350 is that right i i think i'm thinking of this wrong because i feel like this oh here here here i know what we do we'll go back and we'll use our we'll look here there we go oh yeah so whoa yeah that is big so that's two million gas if we go back to our gas calculator that i had from build here we paste this in let's see uh how much this is going to cost us to deploy on mainnet if we wanted to deploy this uh yeah 380 is that right i feel like it didn't update does it go to 38 yeah so dollars to deploy just this contract then when we meant each one of these nfts so if i do the yarn mint you're going to see that each one costs let's see see one of these transactions go by yep this much okay so an order of magnitude less but fifty four dollars okay so 300 some bucks c deploy contract and then each nft that you mint is going to be 54. so if you wanted to min a bunch of nfts this is eventually this model is going to kind of break down and the what you need is a way to kind of like counter factually mint them or find a way to set it up so the buyer could mint them and that's the next thing we're going to move on to so the next uh yarn install and yarn start the next branch of scaffold eat we're looking at here's the fire mitt and the buyer mints is going to try to push that that meeting cost onto fire and ask them to to pay the gas to mint them and so we're going to have to figure out some kind of trick to come up with how in the smart contract to set it up so we can say here is the list of artwork that you're allowed to mint within our smart contract so let's follow these instructions here we pull down the buyer buyer mints uh we are an install we are on start something's breaking there i feel like uh yeah yeah we're gonna bring up our chain i feel like we need to run here we go yeah so we need to do a yarn upload the reason is there's this artwork file so this repo has has pulled the artwork out into its own file so this is really built for i'm an artist go find a nerd friend i'm an artist nerd i can just edit this one artwork file i can get into this artwork and it's the same silly paintings of mine but i can get into this and i can change you know i can put in my own artwork or i can be a developer go to one of my artist buddies have them put in an artwork and then me as the developer can kind of pick it up and run with it so here we go we're going to we've got the yarn chain now we need to do a yarn upload so it's going to go through our artwork and it's going to put our assets into ipfs it's going to get that hash back and what we're going to do is we're going to take all of those fingerprints for all of those paintings and we're going to deploy them with the contract so let's go with our contract for this one this contract is going to take in uh an array of assets for sale so and then and then we've added so we've taken that erc 721 from the simple example and we've added a couple other new fields and this is by the way talking about creators and creator economies uh a great creator can take something like this and add you know one or two little tweaks and create a whole new like financial mechanism to fund something kind of kind of what mp was talking about earlier uh what we're going to do is we're going to add this to say these are the artworks that are particularly on sale and they're going to get a uri to token id this is just for the front end to be able to map things together but a small addition to this and then we're going to create a require statement in here that says hey is this for sale is this a is this a legal ipfs hash and if it is we'll let you through and we'll set it to false so you can only min one of them and we've uploaded everything i think we're ready to deploy this all right here we go yarn deploy and we're going to deploy our smart contract and this is just going to be one transaction one single transaction there it is it's a little bit more expensive let's see let's go to it's it's about as much one contract and one minting but where's our where's our calculator i want to go back to the calculator real quick and see how much this cost uh this this costs us here we go paste this in it is oh there we go 588 okay so for for me the developer for me the artist it was about 580 to put this out there but now i don't have to pay any more gas this this thing is going to be set up so now if we go to local host and we fire up let's see what do we got okay there's our whole gallery okay so we're doing things a little differently here none of these are minted yet we've only deployed we can see that we've deployed our contract right oh oops let me there we go we can see that we've deployed our contract it's out there and we could go ask it you know what's this guy's balance or something like that it's zero there's there aren't any nfts deployed yet there's just our collectible contract that's out there what we need is to set it up so anybody can call this mint item and what we're going to do is only allow them to mint items that are legal and that will be uh any of our pieces of artwork here so let's go ahead let's let's go back to the front end let's try these and make sure it works and then we can get in and start writing some code what i'm thinking is we'll write a small little bit of like pricing functions we've got maybe like 10 minutes left i hope that's okay kind of watching the chat here hit me up hopefully 10 minutes is okay what i want to do is just add just like i said i want to be a developer to pull something off the shelf take something that's mostly working and adds like all i have to do is add the small mechanic or we're going to maybe add a pricing function maybe maybe add a curve to it we'll see uh if if we have a little time but let's make sure that we can at least mint these buffaloes now so let's see it's a bison actually isn't it uh i'm going to instead of i could instead of hitting this button which i could i could go to the faucet and i could go here too but what i want to do is i'm going to go to the wallet let me show you that again there's a wallet down in the bottom left here i'm going to paste in my address i'm just going to give myself like a million dollars or something like that there we go awesome okay so i've got a million dollars of of local funds uh can i as a third party so let's say someone else deployed this contract they've they've paid 580 whatever it's out there they deploy this website they yarn build it and they ship it to s3 or surge or ipfs but it is now public website and i'm a millionaire and i land here and i decide i want to oh i'm definitely going to mint that penguin there we go so i hit min and what happened there let's oh gosh let's let we'll do another one let me clear the there we go it's its own time okay let's how about this unsure hippo here let's mint this hippo and where did it go where did it go right there right there how much was it okay so now the i'm not even gonna go we've got it 200 000 gas so so now what's happening here is the buyer is paying to mint these so the artist can say a one-time fee of my contract here's you know a big list of all my art and then if someone wants to come along and buy those things they pay the gas they mint it and and now they own it and let's let's just grab an incognito real quick and send it from one to the other to prove these things are just standard tokens we can send around uh let's go to your collectibles let's copy this uh oh i think i need to go to your collectibles there we go let's send him let's send him the penguin send him the penguin and hopefully there it is yep okay there we go okay now let's actually write some code here right we've got a we've got a basis of what scaffold eath is we've seen uh nfts now this is kind of like this weird counter factual uh example of nfts what we really want to do now is let's let's put a price function in here so let's go to our smart contract and let's create a un-256 price oh make it public always make it public price and we'll set it equal to let's just do one eighth right one ether okay then what we're gonna do is we're gonna make sure that this mint function is now payable right we want to uh accept funds to this this meant item we want people to send in money and how much right so let's add one more require stamic cue you out the french require and what are we going to require we are going to require that the message.
value which is a global variable that tells us how much money they sent in that has to be greater than or equal to whatever our price is so we're gonna charge one ether and then if not we'll say not enough right okay now let's ship this thing right let's let's do a yarn deploy going to compile it probably give us compiler errors let's see what did i do wrong it worked first try all right so our our new club was deployed it uh does everything with the the the counterfactual uh minting but now oh it's going to cost money right okay so now if it's not going to send any money here what we need to do is get into our front end and wire up this mint button let's see if i can go find it oh look at that first search uh what i'm going to do is see here is oh look we've even got an override so here is right contracts your collectable mint item and you're sending it in and it looks like we're even hard coding gas price i'm going to hardcore one more uh override here is what it's called and i'm gonna say value equals uh part ether one i think i'm gonna have to do like utils here let's see what do we got what do we got uh let's let's just hit save and see what happens first right i did break okay oh just because i forgot a comma okay let's get back over there oh whoops there we go parks ether one there we go okay now we've we've edited our front end and we can push that out to deploy it whatever now people are going to see our gallery and when they mint it's going to cost them one each which we probably should do a better job of maybe we should call this buy and put a one and put a little eat symbol there i don't even know how to make it but i'm gonna say one east by there we terrible ui just terrible but we're going with it okay cool so we've got now our gallery and now we've got a buy button and it's going to cost us one ease it doesn't look like this guy even has oh there he goes there's his million dollars he's ready to go okay now let's see if we can mint this buffalo and pay one eat there we go we see our money go down we see the thing get minted and there we go we own it now and we paid for it so how do we debug let's go over here to bug what we want to look at is this your collectible look at something new has happened here if we look at the balance of the your collectible it is now at one east and if we go here and buy this one right so so we're paying one each we're paying the gas for it and we're loading this contract up now now this contract should have two eth in it right cool okay we've got a problem though oh no we don't have any way to pull this money out so basically the artist has deployed their nft they've set up their gallery they let people counterfactually mint their nfts and pay for them but if we go back to our collectible there's no way for us to withdraw our funds so let's finish out by building just a little withdrawal function here that lets us withdraw that and we can talk about kind of next steps but let me i just want to do this real quick okay so inheritance inherit the ownable pattern the owner will be set to the deployer and then what we want to do is create some uh function down here called withdraw uh it will be an only it'll be a public only owner right we only want the owner to do it and what's going to happen we're going to say message.sender.transfer the address this contract dot balance so basically the owner should be able to get in here and call the withdrawal function and pull out those funds out one last thing we need to do here in this deploy script after we deploy our contract let's do a let's await and we'll say your collectible dot transfer ownership i think it's transfer ownership let's go look oh it's not here yet uh i'm just gonna go with it i think it's transfer ownership so so it's going to start being owned by our deployer account but let's go ahead and transfer the ownership here let's just create a new this will be here is the artist's address here all right uh five six nine f kind of some boring blockies let's see if i can get a better one come on come on we got we we have a second give us a cool blocky it's it's so cool ah no same one okay whatever all right so this is our artist 569f uh we're gonna set them as the owner of the contract so this artist should be able to withdraw the funds from the contract uh once it's deployed everything looks good uh let's see let's let's ship it see what happens all right here we go there we go deployed our contract we've got all of our artwork our app reloads we have a new contract address we go to the gallery i'm going to buy the buffalo for one east i'm going to buy the zebra for one east i'm going to buy the rhino for one eighth i'm going to buy the fish for one eath oh it feels so good oh not for sale what did i do maybe i double tapped one of them i don't know we do own all four of them we can look at our collectibles uh for some reason i could send one back to the artist if i wanted like that okay but what we want to do now is we want to make sure the artist can get in here so if the artist goes here and they go to debug contracts actually let's do it as us first to make sure it doesn't work they go here there's going to be this new withdrawal oh wait first of all four there's four eth in the contract you got you saw it okay where is the withdrawal here we've got this withdraw function that shows up right we've added something new to the contract now we have this new interface in that scaffolding if i call withdraw this should fail caller is not the owner okay so who is the owner can we ask there we go the owner of this contract is five six nine f and guess what that's that dude all right here we go he is about to withdraw where is the withdraw button all right we've got zero to oh we have to get some funds right right we can't withdraw we don't have guests to pay for the transactions but watch what happens when we withdraw from the contract boom boom boom nine grand whoo we rich all right awesome so that is the buyer uh that is kind of a small twist that we can put on an existing repo to go from okay now we're kind of letting people mint and pay the gas to now this thing has a price right we've we've added in this price function and we've tested it and it really it's like a yarn yarn deploy and then it's a yarn build and you ship this thing and someone can go to it and start buying these nfts you basically deploy your contract to whatever network you want and you deploy your app to some kind of static server and you're ready to go it's like a five minute process from from this point uh one thing so let's let's talk about steps now we've kind of we did like a tiny little bit of programming i'm sorry i'm sorry it was just a little bit but there's a lot of context you need to get this printed out okay so here we go we've got this nft we've got the price function we've got it set up so you pay one ether what are what are some great next steps so one thing i would really love uh for you to check out once you have a price function think about how you could do a bonding curve so bonding curves in uh those those fungible erc20 assets they need some fancy math to figure out like the the area under the curve and ain't nobody want to mess around with that you could just use the band core model uh but uh if if you're using nfts nfts are purchased one at a time in a very kind of like discrete one at a time way which makes it perfect for a bonding curve because what you can do is just create a multiplier and and the way i did this is here we did this a fun one where you could you could have a multiplier of say uh one three three seven and a denominator of so you have a numerator and a denominator okay so let's just call it a multiplier for now let's just say the price so we go back to our price function okay each time let's just do it right here each time someone purchases one we make sure that the price goes up but now we say price equals price times which is a 0.1 right so now that price is going to go up and each one that gets purchased it's going to go up more so just by putting this little function in here we created this sort of like really cool kind of like liquidity curve that sort of stores the money and instead of the the artist getting in here and withdrawing right the the liquidity is gonna stay in the contract and people can lock up funds and mint in an ft but then they could come back here at any time and maybe burn the nft and the price would go down right but here's here's the gotcha here you can't use this point one like this in in solidity what you need to do is something like one three three three seven and then you go like that and then out here you divide by one thousand right can't use decimals you need to use a numerator and a denominator there's a little little solidity gotcha there but now this should i don't know oh should we just see if it works let's oh no it's not gonna work because we're gonna need to load the price function into the front end and pay that every time i i don't think i want to dive into that i think we've kind of like reached the the time limit here uh so so for for next steps grab that simple nft grab that buyer mint put in a price function see if you can set it up so that price works on a curve right there's there's so many fun things to do uh next steps check out the active branches so if you go to scaffold eath you go to these branches here there's so many things here say you want to look at like commit reveal or you want to look at bonding curves or you want to look at like a denial of service attack on a contract like what what can i learn uh also if you're learning solidity by example is really good i should have pointed this out earlier really nice clean uh examples of solidity where you can get in here and say what what is a reentrancy attack and can i copy and paste it and and put it right into scaffolding and play around with it but next steps you've got scaffolding you've got nfts you've got a buyer mints get in here and look at the next like what cool things are getting worked on if you go to branches and you sort by active there's so many cool things getting worked on by people uh the rad wallet the a merkle buyer okay this is this is really good this is really good so just talking about that that counter factual we put all the finger contract and then you can mint them counterfactually uh checked out this branch this branch is using a merkle distributor so you've got all of the ipfs hashes in a merkle tree and then when you go to mint it you have to prove that it exists in that tree and then you can mint from there so just another twist on this this same nft build that that is actually like uh scalable up to like probably like you know thousands or tens of thousands or a hundred hundreds of thousands of of artwork say you have a hundred thousand pieces of art and you only want to get a five that someone else wants to pay the gas for you could use something like this uh let's see we're closing out here nft vrf stuff uh let's see buyer mints we just got that one uh chain link so lots of chain link stuff um little games tenderly example uh uh chain link more chain link tutorials ooh swaps and ave so within uh scaffold heath we have an ave branch and we have a swapper see we have a lender and a swapper so you can like right off the shelf you can have uh basically like a uniswap like ui right in your app or an ave like lending ui right in your app so maybe you wanted to create some kind of like nft thing where they burn the nft and then they get along on ave or something like that this is a great place to start and and kind of like play around with what things exist and then what things can i take off the shelf and tweak and build what i want to build from there all right i think i think i'm about done i think i have like everything covered 100 open to questions i can hang out uh open open to whatever uh i'm austin griffith again on uh on interwebs you know how to find me uh my dms are open on twitter if you have questions and you can always just google scaffold eath and i think there is a support button yes so if you go to scaffolding and you want to talk to other people that are building with scaffolding hit that support button and it's going to take you to our telegram and i'll see you there awesome anything else any questions i'm checking the chat i'm checking the chat what do i see oh this is a private chat i think i don't even see the chat hello merrick hey hello we are back for the q a session so yeah we have a few questions let's see let's start with the first one the first one i think can go to either review so what's the next for nfts after the hype is gone so maria would you like mp would you like to start well what's next you have to think that nfts are actually smart contracts and they're tokens that live forever in the internet so after the hype is gone i guess the nfts are there um you know the technology remains uh and the hype you know a lot of people compare it to the tulip hype and what happened when the tulip hype ended well the tulip industry stayed in the netherlands so i think the technology will stay simply a lot of people lost a lot of money but the tulips are here today still oh austin would you like to add something yeah no i think that's that's a they're they're we're going to have these times in in this uncontrolled ecosystem where speculation puts it pus it pushes us up way too far and then we see a fall and there's a lot of people in those bear markets that are really like thinking about at the corner of technology and art like what cool things can we build here and what cool structures can we use to fund the next things that we build here so i think that like yes there's a lot of greed in the space right now and we have to add a disclaimer like there's a lot of greed here but the the technology and the tooling any old dork can pull something off of github and add a pricing function and create a gallery not to i mean yes that person could make money yes that could that person could raise money because it could be simulation here but there's also these really interesting mechanics that are getting created and those like mp said are going to be around for longer than i am hopefully well uh i i i i might add something i really see the nft craze now the same way the ico back a few years ago and like it was a lot of icos a lot of money a lot of products that didn't really lead to anything and a lot of people earned a lot of money and even more money lost even more money but something was supposed to stick and what sticked was that fight and i remember like during the ico crate there was this project called maker dial and i'm like that was so yeah it was hard the dollar is not cool anymore you know like this is not interesting person i'm not looking at that and now the maker turned out to be ignite for the deaf eye and you know it's still one of the biggest and there's so much going on with that so it's like you can see the direction you can see the general direction the trajectory that the industry is going but you never for me at least i'm never gonna know what it's gonna be exactly but i can see something gonna stick what it's gonna be is is is it gonna be crypto punks or is it gonna be back to cryptokitties or is it gonna be you know something completely new that we never thought about that we like looking now and it's like yeah this is not interesting hard to jump right yeah the only thing that we don't want to talk about cue for predictions apparently come again the only thing that we don't have to do is ask you for predictions since you didn't hit it right with maker dial from all things i'm you know central transparent so yeah definitely i do this so uh here is another question and i think again it can really go to any of you so how does funding uh is that the second one no i think uh also what's the easiest way to meet your own nfts and i think there is more than one good answer so who else starts there's lots of great platforms out there yeah there's lots of i mean you've got open c is the old classic there's zora there's foundation there's a lot of platforms for you to meant this but really the superpower here is what we just did over here with github right anybody should be able to pull these things off of a shelf and mint them themselves and add their own mechanics to their smart contracts i mean careful with your smart contracts they're you need to do a lot of auditing but uh i i would push folks toward building it yourself build something cool add something new to the space that doesn't exist rather than take your your blender rendering and mint on foundation even though those are very dope also and for for someone that can't pull something off the shelf a great way is to upload it to openc and have it minted there if you've got a developer friend or you're a developer friend pull one of these repos off the shelf and try doing it that way and hit me up if you have questions [Music] yeah i just want to add that there is a sort of difference because because some platforms are actually not permissionless and others are for me and not permission list means that you actually have to apply for the platform and then there's like a long process until you get approved so you know always look for the permissionless platforms opencs fantastic variable is fantastic as well because you don't need to you know do anything to enter you just need an east wallet a little bit of gas and your art and then you can just meet very easily also the documentation is always up to date so yeah in case of you know when in doubt try to go for the permission last ones you don't need the hype even if foundation it's an amazing platform you you know you probably need to test first nfts if they work for you as well because they're not for everyone so i i would love to i would love to add that i think it's great that nft space is a is a great place for technology that can create their own nfts in a sense creating new code and new value new experiment with new ways of doing entities but also for artists that you don't need to have all the technical knowledge and here comes the next question i think that's going to be particularly for mp so how that's finding content creators using nft exactly works if i decide to find a novel author and i'm getting in a token or anything in exchange it is kind of ico for content creators so a question at the same time yeah it's a really good question uh thank you mihawk so basically you know there's there's two options that we looked into in my presentation one option is actually for content creators to meet a representative nft of what they're doing uh like the open source science one and then you would buy that nft and you would unlock also private content for you via that nft you get the token yeah you get the nft that it's representative to that particular research so that's one of the uh one of the options then the other two options uh the bounty token for the auctions and the right novel uh that you actually mentioned here are founded via a platform that's called mirror in mirror of course you need to enter some sort of game to access the platform and it's not very easy right now but it's gonna be more easier you know they're in super super alpha i actually got in last week after six weeks of trying and basically you donate to that a novel author and you know it depends on the setup that they have uh you know that they have decided the the the author is actually you know getting the novel token funded you would get them the the token and then you can trade it in unisop or you know maybe they do another kind of auction where you know the novel token has no value so it depends on on every person that designs their own crowdfunding mechanism one thing to add to that is just the the long tail like sure it's an ico but instead instead of like 18 orgs raising millions of dollars it's more like 18 000 people raising a small amount of money to continue right like it's it's all those creators down the long tail that are that are selling to their communities instead of an ico like like we think of classically but that is not something that newspapers would cover right so we only hear about those super expensive if you're not yeah play space so close to you which is a little bit unfortunate and yeah absolutely and you also have to think that you know authors and artists and musicians they're they're usually bound to a lot of middlemen so you know what you pay for an album is not what the artist gets there's a whole industry and a lot of middlemen that have no business being there as well so when you fund a novel or an nft you that goes directly to the artists that you love and that's super important yeah lovely let's let's go for the next one austin is a little bit pixelated i think that the reason might be that he's in denver over the ocean but i think the sound is open no it's my it's it's my eth2 node let me shut it off just a second it's totally using up all my bandwidth and now you're telling us okay let's go let's let's give him a little a moment to disable it and i'm gonna read the question in the meantime my question is what cool stuff can we create after the current hype more stuff that creates hype more marketplaces nfcs are super versatile so you can use them for games uh you know you can use them as prices for games you can use them to unlock games you can use them to you know create communities you can you know you can use them to for for anything there's even decentralized exchanges for a nfts and uni swap is going to have a functionality to give liquid to be a liquidity provider for nfts so there's yeah there's so much but maybe the guys actually are better at answering this one than me i i think of like i love thinking about utility just just a few things like thinking of nfts were collectibles and tell and and what are some of those intel's right and and we have you mentioned it a community like a chat right i i you can mint in in you can mint a nifty ink right now and go to collab land and say anybody who has this nifty ink can get into this telegram group so there's one thing we just have like a gated telegram group if you own this nft and we can think of all sorts of different mechanisms on how to sell or distribute that nft but that's that's just one of them right uh the the instant liquidity what about if we think more like utility in terms of um like a certificate or kyc or some kind of nft that says hey yes this person is kyc or this person can drive right my driver's license could eventually be an nft so i think that like the utility angle is really fun uh you can use these to vote right anybody who owns any nifty inc can then use can then vote on our platform of whether oh no i think i just my bandwidth dropped out can vote with those right and the cool thing about that utility is it's off chain you can hold an off chain vote with just signatures from nft holders and nothing has to go on to the mainnet ethereum no one has to pay gas but you still have that utility that you get from that nft yeah and let me add that um the gaming i personally love the gaming as the that's my favorite one uh i think about a lot about artists recently but i guess that's because of the hype and everything but i think it would be really interesting to see more items in the games that kind of cross it goes beyond one game and becoming part of you know i think like in multiple universes but i would like possibility right like a game asset could go into another game or one game can create a bunch of assets and someone else can use those assets completely permissionlessly right i don't you don't need my permission to take nifty inks and do something else with them and i think we're going to see a ton of that i would love to see that i think it's happening and i would like to add that there are those virtual galleries and you can help me out with naming those but we've been as a company on one of the companies and us we went to a virtual gallery and there was a wall full of crypto punks and the wall itself was more like 100 like 100k and like whoa i was like we were looking at that that was that was pretty crazy and i think that's gonna be that's gonna be a thing the last bubble it was all about orange lambo lamborghini and now that and now it's like yeah this is so old school and this is so lame now if you want to show that you're important person in crypto space show me your gallery right i don't want to see a wall i want to see how many tokens you have i don't want to see your lambo what i want to see is your gallery i have a space in crypto boxes that's worth more than my car my i i have a floor on crypto voxels where i have my nfts on the wall and that parcel is worth more than the vehicle i drive does your wife know about it well that's good let's hope she's not watching we want a link can you can you send a link or is that us yeah for sure no i'll find it just a second okay let's go let's go for another question we have more and more question i think we're gonna do maybe two more and then we go to a networking session so wukash is asking can an artist get stuck with their earnings if they sell for too low to withdraw i'm not sure if i follow the questions do you do you understand yeah i do and no actually you're not gonna get stuck with your earning because you you know transaction fees and ethereum are not that scary for a simple transaction to withdraw you obviously should get informed and know how much are you are you selling your artwork for because you actually have to put a price on your artwork so make sure that you research transaction fees before doing that and you won't get stuck okay so that's regarding the because the fees are expensive and the withdrawal might be the fee might be more expensive than we go yeah i think that might actually happen if you sell it for really cheaply like for a dollar or two and the fee might be five dollars so that might happen so you always need to yeah yeah but if you're if it's not that i want to uh argue but if you're minting an nft you're already spending let's say 100 usd maybe so obviously you're not going to sell the nft for one usd unless you don't like money then then sure why not but and i think it's worth to mention everybody knows that here but just you know for all the people that just joining space right now there is tunnels lt l2 work layer to work so the prices are going to drop probably in just a few months this is all around the corner people are releasing alphas betas so that happens all the time so i think this year this year we finally see everything finally getting together you can buy nfts for a dollar it like so we built it on a side chain and it upgrades to ethereum so it's like 200 if you want that thing to go to mainnet or like a hundred dollars right now but you can buy and sell them for like dollars on a side chain and that experience is going to translate really nicely to l2 when we see all these l2s come out that your that nifty ink will be basically a drop in replacement we'll take it and it'll be optimistic ink and and we'll just have it and it'll scale on l2 and you will be able to buy and sell artwork for dollars yeah that's very good point so thank you for you know for mentioning that okay and i think we have the last question that one last is a little bit weird but let's see uh do you think nft will have usage in military area too i hope not i'm pretty sure it will i can't think of any but you know you know the military they'll always find a way to use everything but maybe they're ranked each each person outranks each person their key pair has a specific nft that shows what rank they are within the in the like oh yeah i can sign this nft that shows that i'm an og captain of something i don't know that's scary that's scary i don't want to go down nfts of the military i don't even want to touch that yeah yeah i can't really yeah someone actually they're i think that i'm not sure because we're on youtube facebook twitter many different places i'm not sure where this one coming is but someone says buying some tanks on the blockchain as a joke i guess but actually the permission to have a gun could be nft right yep that that would be interesting though but what would be the reason why i want to transfer that or someone already but like i mean there's arms trades that happen all the time if that was on the blockchain it would be really obvious who moved weapons to who right and if we need that kind of thing to be public maybe that is a good use for it i am i'm seeing a couple of problems with that i want to get into it well i think we should conclude that we don't see any straightforward military usage for nft but you know you never know you never know we we all we all hope not too much guys um i'm super happy for hosting you today thank you thank you for joining us we have a networking session can we can we get an address we have a networking session on discord and if you still have time http http colon slash slash bitly slash beat dopply xerox chat so if you still have a few minutes and you would like to join there maybe there might be some additional questions um and yeah everyone who's watching us please join us uh on on our discord we will post the link you can see the link here we will post the link on facebook youtube and all the other platforms as well and yeah see you there in a bit thank you very much bye thank you
Automatic transcript — names and jargon may be misspelled.