Current location: Current location: Home > html > Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep201 Text
Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep201
[html] Time: 2025-07-11 11:38:08 Source: AIHackNode Author: kotlin Click: 180 times
array then returnbreed of I and ai job loss resetthen outside of thiswe're going to say cumulative sumplus equals chance array of I let's saymoded RNG equals 25 and if it's 25 itshould be a shivba Inu because that'sbetween 10 and 30 so we're saying ifmoded RNG which is 25 is greater than orequal to cumulative sum which right nowis zero and it's less than and the modis less than the cumulative sub plus thechance array of I which is going to be10 return breed of I cumulative sum iscurrently zero plus chance array of Iwhich is 10 is going to be 10 and thisis not true because mod RG is 25 sosince this is not true we're going tomove to the Second Step which is justcumulative sum plus equals chance arrayso cumulative sum will now be equal to10 and then we reach the end of the forLoop so we restart I is now one so let'stry this again moded RNG is greater thanor equal to cumulative sum okay that istrue cumulative sum is 10 moded RNG is25 and modded RNG is less thancumulative sum plus chance array of Iwhich is 30 so we're saying 25 is lessthan 10 + 30 which is 40 return breed ofI this is true so breed of I would betrue and I at the moment is one and ifwe scroll up that's indeed the shibbaInu so that's how this function is isgoing to work it's going to get us thebreed from that modding bit and then iffor some reason some really wacky stuffhappens here we want to just go aheadand add a revert right because we shouldbe returning a breed U but if we don'treturn a breed we should just revert sowe're going to create a new error at thetop random I PFS nft uncore uncorerange out ofbounds then down below we're just goingto say if for some reason you don'treturn anything just do a revert randomipfs nft range out of bounds and now wehave this function okay so now we canget the brief from a modded RNG so backin our fulfill random words functionlet's go ahead and we'll say We'lluncomment this we'll saybreed dog breed equals get breed frommodded RNG pass the modded RNG here andlet's move this safe Min down below usgetting the dog breed just so we canmint and and add the dog breed at thesame time so we're going to go ahead andsafe Minhere now we could do a few things to setthis dog breed here we could create amapping between the dog breed and thetoken U and then have that reflected inthis token U function or what we coulddo do is we could just call a functioncalled set token u in the open Zeppelinerc721 you have to set this token URIfunction yourself however there is anextension in the open Zeppelin codecalled earc 721 URI storage and thisversion of the earc721 comes with a function called settoken URI where we can just call settoken URI and this will automaticallyupdate that token's token U to whateveryou set it as so we're going to use thisextension this set token u in ourcontract the way that we do this isinstead of doing token ERC 721 erc721soul we'll do token erc721SLextensionsSLC 721 URIstorage. soul and we'll say random ipfsis ERC 721 U Storage now what's what'scool is that our Constructor will stilljust use erc721 because erc721 U Storageis extending erc721 and then thiscontract just comes with some additionalfunctions like set token URI so rightafter saf mint we're actually going tocall set token URI with this new ItemID and then we're going to give it thatbreedstoken U we're going to give it a stringhere that relates to whatever breed thatwe just got based off the dog breed herenow to do this what we could do is rightat the top in our nft variables we couldcreate a string array internal called sdog token Uris we can make this constantwhere it would just be this array of allthese strings that we created but maybein our code we want to make this alittle bit more variable and we want toparameter ize this and that's exactlywhat we're going to do so we're going tocreate this string array internal soredog token uis which is just going to bea list of these URLs or these Uris thatpoint to stuff like this we're going todo that in our code so that when weupload any image that we want to ipfs wecan then upload this s dog token youarise accordingly in our Constructorwe're actually going to take anotherparameter called a a string of sizethreethree memory dog token Uris we're goingto pass as a Constructor parameter thesedifferent dog tokenuis so we're going to pass this list ofdog token uis of course zero is going tobe the token URI of the Pug one is goingto be the shibba Inu and two of courseis going to be the St Bernard so we'regoing to pass it this list of dog tokenuis and then down in set token URI fromthat that list that we created we'regoing to set the token URI of this tokenbased off of that array of the U256 version of that breed we're castingthis dog breed back into U 256 to getits index with that we now have a way toactually programmatically get a provablyrandom nft with different Randomness fordifferent one of these nftsnow let's go back up to our little ourlittle comments we made here we mintednft we trigger chain L vrf to callrandom number we got the Rarities downwe got the minting down awesome okay wedon't have this part though users haveto pay to Mint an nft and the owner ofthe contract can withdraw the eth okaythis is stuff we've already done beforethis should be pretty familiar here soback in our request nft function we'llmake this a public payable and all we'llneed to do is just say if message.value is less than some mint fee andactually let's go back to ourConstructor we'll create a mint fee un256 mintfee and then we'll do un 256 internaliore mint
(Editor in charge: python)
Solidity, Blockchain, and Smart Contract Course – Beginner to Expert Python Tutorial - Ep33GenAI Essentials – Full Course for Beginners - Ep61
Related content
- GenAI Essentials – Full Course for Beginners - Ep53
- Generative AI Full Course – Gemini Pro, OpenAI, Llama, Langchain, Pinecone, Vector Databases & More - Ep128
- Generative AI Full Course – Gemini Pro, OpenAI, Llama, Langchain, Pinecone, Vector Databases & More - Ep80
- Generative AI Full Course – Gemini Pro, OpenAI, Llama, Langchain, Pinecone, Vector Databases & More - Ep211
- Artificial Intelligence Full Course _ Artificial Intelligence Tutorial for Beginners _ Edureka - Ep36
- Generative AI Full Course – Gemini Pro, OpenAI, Llama, Langchain, Pinecone, Vector Databases & More - Ep177
- Harvard CS50’s Artificial Intelligence with Python – Full University Course - Ep105
- [Hindi (auto-generated)] Machine Learning FULL Course with Practical (10 HOURS) _ Learn Free ML in 2025 _ Part-1 - Ep59
- Solana Developer Bootcamp 2024 - Learn Blockchain and Full Stack Web3 Development - Projects 1-9 - Ep70
- [Hindi (auto-generated)] Machine Learning FULL Course with Practical (10 HOURS) _ Learn Free ML in 2025 _ Part-1 - Ep34
- Generative AI Full Course – Gemini Pro, OpenAI, Llama, Langchain, Pinecone, Vector Databases & More - Ep2
- Harvard CS50’s Artificial Intelligence with Python – Full University Course - Ep120
- Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep186
- Generative AI Full Course – Gemini Pro, OpenAI, Llama, Langchain, Pinecone, Vector Databases & More - Ep168
Wonderful recommendations
- Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep182
- Harvard CS50’s Artificial Intelligence with Python – Full University Course - Ep25
- Artificial Intelligence Full Course _ Artificial Intelligence Tutorial for Beginners _ Edureka [DownSub.com](1).txt - Ep10
- Generative AI Full Course – Gemini Pro, OpenAI, Llama, Langchain, Pinecone, Vector Databases & More - Ep232
- GenAI Essentials – Full Course for Beginners - Ep83
- Harvard CS50’s Artificial Intelligence with Python – Full University Course - Ep121
Popular Clicks