Current location: Homepage > swift > Web3 Developer in 2024 Roadmap_ Solidity, Smart Contract, and Blockchain Development [Full Course] - Ep52

Web3 Developer in 2024 Roadmap_ Solidity, Smart Contract, and Blockchain Development [Full Course] - Ep52

2025-07-11 13:37:10 [php] Source: MetaScripta
will give us some information onnfts so you can ai taking jobssee we have use totalcount here which was to get the totalcount of unique nfts on our smartcontractwe can use total circulating Supplywhich will get us the total number ofentities in circulation for a givensmart contract so what this will give usis the total number of claimed ERC 1155tokens for a specific token so you cansee that implementation for ERC 721 isdifferent than ERC 1155 so this is howyou would configure it for an ERC 721but if we look down here we have a tokenID that we have to give it for ERC 1155only and that's going to give us thecirculating supply for that specifictoken ID and you can view the returnvalue uh it's going to give us back abig number which is why we always usethe two number to convert it to a numberthat we can then use and display solet's get the total circulating Supplyhere so again we're going to use thathookin our application here so we'll getour data and we'll call this totalcirculating Supply and we'll use the usetotal circulating Supply hook again weneed to give it our contract but becausethis is in 1155 we also have to give itour token ID and we want to check fortoken ID 0 which is the only nft that wehave claimed right now through thiscontractso just like our total nfts down herewe'll add some more text here we'll saytotal circulating Supply and then we'llcheck the loading status and thendisplay our total Circ our totalcirculating Supply and then we'll justput token ID 0 because we're checkingthis for token ID 0. so if we come backto our application here you can seetotal circulating supply for token ID 0is 3 and we had claimed a few more nftsfrom before but we can always doublecheck to see if that matches we comeback to our contract here and you cansee for token ID 0 we have a supply ofthree right here on of our contract soagain if we were to claim one more nftwe'll confirm this hereso we claim one more nft we should seeour total circulating supply for tokenID 0 increase to fourand there you go you can see we now haveFork circulating a total circulatingsupply of token ID 0 is now four soagain you can look at the documentationsthat we have and you can see all thedifferent react Hooks and all theinformation that you're easily able toobtain from your smart contracts withjust a few lines of codenow let's view our owned nfts here againin order to view our own nfts thoughwe're going to need to get the walletaddress of the wallet that's connectedso we display their correct informationhereso coming back to our code editor hereat the very top I'm going to createanother variable here called address andwe're going to use the use address Hookfrom third web again that gets us thewallet address of the connected walletthen we can use another react hook herewe're going to call this owned nfts andwe can use the use owned nfts hook andwe give it the contract address we'rechecking the owned nfts for and then thewallet that we're checking the ownednfts for because it is an ERC 1155 it'sgoing to give us back an array of theowned nfts that we have per token IDso what we'll have to do in this lastsection here would first check uh theloading status of the owned nfts hereand if it's still loading we'll just puta loading hereand if it's not loading what we're goingto do is take that array of owned nftsthat we get from the react hook andwe're going to map through each one andin return we're going to display sometext here we're going to have to givethis a key uh and then we can give thisa key of nft dot metadata dot ID becauseit'll have its unique ID hereand then for the text here we'll justsay tokenID number and we can get the token IDnumber again from nftdot metadatadot ID and then after that we can sayowned and what we can get from here isthe total amount of owned nfts for thatspecific token ID and we get that bygetting the nft and within that we canget the quantity owned and that's goingto give us back the token ID and thenthe number own that we have and againthis is getting it from the array ofowned nfts that we get returned from theowned nfts react hook so we look at ourapplication here we can say token ID 0owned we have four now if we come overto our ERC 1155 smart contract let's goto token ID 2 here let's add a claimcondition really quick we're just goingto add a public one and we're going tomake it a free mintlet us save this and what we're going todo here is we're just going to make thisa free claim confirm this transactionwe're going to claim one of the nfts andonce we claim it our owned nfts shouldupdate with the proper informationso we have our claim condition set let'sgo and claim an nft here so let's claimone of these we're just going to claimit directly from our dashboard hereand you can see we claimed now one ofthose nfts so if we come back hereyou can now see our owned nfts we nowget updated data here saying that tokenID number two we now own one so againthis information will update based onthe interactions on our smart contractand again we're able to do this withjust a few lines of code using thesereact hooks so that does it for our ERC1155 nft we did a few things slightlydifferent than we did with the ERC 721nft we went over and learned how toaccept custom erc20 tokens and chargethat instead of native currencies on theblockchain that were deployed to we alsolearned a little bit more about usingthe documentations and how we can findspecific react hooks to give us certaininformation and data on our smartcontracts we also covered thedifferences of interacting with ERC 1155versus ERC 721 you can use the samereact hooks but

(Editor: swift)

Recommended articles
Hot reading