How to Build an NFT Marketplace - Solidity Tutorial (for Beginners) [2022]

แชร์
ฝัง
  • เผยแพร่เมื่อ 19 ก.ย. 2024
  • Learn Solidity by building a smart contract to trade NFTs. Watch this introduction to blockchain development and Solidity basics for beginners.
    GitHub repo: github.com/hus...
    Any questions, or struggling to follow along?
    Join my free Discord server: / discord
    Follow me on Twitter - / husn_ai

ความคิดเห็น • 94

  • @dagumak
    @dagumak 2 ปีที่แล้ว +7

    Lol I like your humor. Your channel is small now, but I hope you continue the grind and become a massive channel one day!

    • @husnain9778
      @husnain9778  2 ปีที่แล้ว +1

      Thanks dude, really appreciate it 🙏🏼

  • @Инвестициикриптахайпы
    @Инвестициикриптахайпы 2 ปีที่แล้ว +1

    Wow, you explaining is great! It's so hard to find good explanation about smart contracts but you are doing it very well! So I'll look forward a new videos about smart contracts!!

  • @divyanshverma7779
    @divyanshverma7779 2 ปีที่แล้ว +1

    Bro, I am glad to see your videos on the topics everyone is exploring right now. I'll surely help you catch more subscribers. Just keep on doing the needed.
    Keep on posting more crash courses and other technical cryptocurrency stuff. There are so many on youtube but yours is raw and that is what's unique cause most of the people who are viewing you are not from the technical background or they are still learning. I think your language of teaching is an understanding one.

    • @husnain9778
      @husnain9778  2 ปีที่แล้ว +1

      Thanks bro, I'll try to keep it up 💪🏼

    • @divyanshverma7779
      @divyanshverma7779 2 ปีที่แล้ว

      @@husnain9778 Hey, can we catch up somewhere on an email address or Google Meet. There is an idea and I want to discuss it with you.
      Looking forward to hear from you.

  • @thebackendguru
    @thebackendguru 2 ปีที่แล้ว +1

    Lool, that entrance had me hitting the like button hahaha

  • @safsafaf2838
    @safsafaf2838 2 ปีที่แล้ว +3

    It is hard for me, I have watched it. I am going to work with easier things. But I promise, one day I will build an nft marketplace like you and because of your great explenation. Keep working man, It is really nice video

    • @husnain9778
      @husnain9778  2 ปีที่แล้ว

      Really appreciate it 🙏🏼 Wish you the best on your web3 journey.

  • @almostadecentgamingchannel6190
    @almostadecentgamingchannel6190 2 ปีที่แล้ว +2

    Great video!!!! Can you do a complete tutorial of this? Like the frontend of the NFT Marketplace and how to call the functions in the frontend? Also a type of auction for the NFTs!! Keep it going. You are the best in this type of content by far.

    • @husnain9778
      @husnain9778  2 ปีที่แล้ว +2

      Thank you! Working on something similar right now.

    • @setarose366
      @setarose366 2 ปีที่แล้ว +2

      @@husnain9778 Hey buddy, any update on this? I second the comment "You are the best in this type of content by far." by Almost a Decent Gaming Channel

  • @lakdsfnoadubi
    @lakdsfnoadubi 2 ปีที่แล้ว +1

    thanks for the tutorial, is clear, in detail explained and fun(the last second when you jump in the wall, lol), I will be waiting for the next one!

    • @husnain9778
      @husnain9778  2 ปีที่แล้ว +1

      Thank you 🙏🏼 Glad you enjoyed it and found it useful.

  • @richchar6478
    @richchar6478 ปีที่แล้ว

    Very good instructional. Moving on to your testing video next. Looking forward to see what you release next 👍😁

  • @premiumrealtyng
    @premiumrealtyng 2 ปีที่แล้ว

    Finally done watching. I really learnt a lot from this video. Thanks for doing this. It helped me understand smart contract better, because it is so beginner friendly ❤️

  • @aminnaseri7124
    @aminnaseri7124 2 ปีที่แล้ว +1

    Waiting for your next video to come out, hopefully you'll build a simple front-end as well cause that's gonna get a lot of views

  • @AbdennourKhelfi
    @AbdennourKhelfi ปีที่แล้ว

    I don't know why amazing creators like you don't get enough credit

    • @husnain9778
      @husnain9778  ปีที่แล้ว +1

      Really appreciate it ❤ I'm actually really grateful for the response on these videos - far better than I could've expected.

    • @husnain9778
      @husnain9778  ปีที่แล้ว +1

      Also, having just 3 videos on the channel can only get you so far 😅

    • @AbdennourKhelfi
      @AbdennourKhelfi ปีที่แล้ว

      @@husnain9778 i really wanna learn more from your channel ❤️, i like the way of explaining things through real examples.

  • @gekka-group
    @gekka-group 2 ปีที่แล้ว

    Thank you a lot, it was my 10+ video I watched , and this one is the most understandable. 🤙👍

  • @cristianc4238
    @cristianc4238 2 ปีที่แล้ว

    Awesome, you have a new subscriber, thanks for the video!! Keep up the good work mate!!

  • @igetpaidtocode
    @igetpaidtocode 2 ปีที่แล้ว

    Top tier explanation I’ve been looking for this long time! Thanks man keep up

  • @alekhyadiwakar
    @alekhyadiwakar 2 ปีที่แล้ว

    Thank you soo much for this wonderful coding for our own Market place.. everything is Cristal clear and helped me to create a market place 🎉🎉🎉🎉🎉🎉

    • @husnain9778
      @husnain9778  2 ปีที่แล้ว

      Very happy to hear that 👏🏼 🥳

  • @nisamudheenc2830
    @nisamudheenc2830 2 ปีที่แล้ว +2

    Well done keep doing

  • @aradhya6270
    @aradhya6270 2 ปีที่แล้ว +1

    Great content ! Learned a lot . Thank you :D keep them coming .

    • @husnain9778
      @husnain9778  2 ปีที่แล้ว

      Thank you! Glad it could help 🙂

  • @bart5840
    @bart5840 2 ปีที่แล้ว

    Thank you for this video. You answered so many questions of mine. Keep it up:)

  • @premiumrealtyng
    @premiumrealtyng 2 ปีที่แล้ว

    I really enjoyed this video 🚀

  • @jiucki
    @jiucki 2 ปีที่แล้ว +1

    It was funny and I learned a lot. Keep it going!

  • @Raj-jz4fc
    @Raj-jz4fc 2 ปีที่แล้ว +1

    Thanks Friend,
    Between I subscribed your channel in hope that you will make more Video on DEFI.

  • @abdulrafay1951
    @abdulrafay1951 2 ปีที่แล้ว +1

    Thank you bro, subscribed and added in watchlist :D

    • @husnain9778
      @husnain9778  2 ปีที่แล้ว +1

      Much appreciated 🙏🏼

  • @chooseForYourLife
    @chooseForYourLife 2 ปีที่แล้ว

    Thank you so much for kind explanation for line by line. It really helps me understand the step-by-step. :) However, sound is a bit small, so please make it a little louder please ^^

    • @husnain9778
      @husnain9778  2 ปีที่แล้ว +1

      Thank you! Will definitely keep that in mind for next time 🙏🏼

  • @davidyomi7692
    @davidyomi7692 2 ปีที่แล้ว +1

    Moreeeeee pleaseeeee

  • @Evan-xh4gc
    @Evan-xh4gc 2 ปีที่แล้ว +1

    well packed solidity tutorial included, next lets destroy opensea lmaoo

    • @husnain9778
      @husnain9778  2 ปีที่แล้ว

      opensea be shaking right now 🤔

  • @jadelaawar
    @jadelaawar 2 ปีที่แล้ว +1

    PLEASE MAKE THE FOLLOW UP VIDEO. I know you didn't get 1k likes but PLEASEEE

    • @husnain9778
      @husnain9778  2 ปีที่แล้ว +1

      Thank you so much for your support! I wasn't too serious about the likes target, I'm actually flattered by how well the videos have been doing and will make sure to make a follow up one. I've just been terrible at being consistent 😅

  • @user-qz2qy9qr7x
    @user-qz2qy9qr7x 2 ปีที่แล้ว

    nice bro, keep going and 谢谢。

  • @kkcheah6402
    @kkcheah6402 2 ปีที่แล้ว +2

    Thanks for the tutorial, it was very insightful. I do however have a question, when IERC721 is called from the marketplace contract, since the interface only has transferFrom( address from, address to, uint256 tokenId), how does it actually perform the transfer as that just seems like a declaration of arguments after a function name whereas the openSea NFT codes have the { _transfer(from, to, tokenId) } which i assume is where the real function is located to actually transfer the token? Much appreciated if you could clarify. i know there was some sort of explanation around 26:20 but I still couldn't understand =(
    Edit: my guess is that it actually calls for the token contract and gets the instruction from the token contract which has all the functionalities of ERC721(Cause its an ERC721 standard token) to perform transferFrom function. In that case, is it possible to just use token.transferFrom(from, to, tokenId)? Of course i could be totally wrong so feel free to clarify!

    • @husnain9778
      @husnain9778  2 ปีที่แล้ว +2

      You seem to be right on track. transferFrom() is the public function that gets called, and this consequently calls the private _transfer() function to execute the actual operation (it's sort of like the "real function" as you've put it).
      Our contract doesn't need to know how transferFrom() works, it just needs to know its inputs, outputs, and visibility (and that's what we specify in the interface).
      "is it possible to just use token.transferFrom(from, to, tokenId)?" - If "token" is just the address of the external contract, then no. The token address needs to be cast as an interface and only then we can make the function call. Otherwise, the compiler wouldn't know how to properly structure this.
      Hope I understood your question correctly, and that this was a somewhat satisfactory answer 😅 Also, welcome to the Discord group!

  • @edwassermann8368
    @edwassermann8368 2 ปีที่แล้ว

    nice tutorial. Thanks!

  • @thilan.dissanayaka
    @thilan.dissanayaka 4 หลายเดือนก่อน

    wow. that was awesome!

  • @sudhanshukumar2326
    @sudhanshukumar2326 2 ปีที่แล้ว

    You are doing a great job!

  • @kamalsharma4866
    @kamalsharma4866 2 ปีที่แล้ว

    LOVE YOU BRO.

  • @emilykamperman2335
    @emilykamperman2335 2 ปีที่แล้ว +1

    Hey maaan:)) i do have a question tho, not too directly related to the vid, but how does the owner of an nft marketplace make money? Like in terms of also when customers pay minting fees, who does it go to, does the marketplace need contracts or smth to get on the blockchain and how much do they have to pay for that? i have very little knowledge about it and am finding it rly hard finding videos that explain those aspects clearly and directly. And i love the way u explain shit so a response would be mucho appreciated:))))

    • @husnain9778
      @husnain9778  2 ปีที่แล้ว +2

      Hey, thank you! The way most marketplaces typically make money is by charging both the buyer and seller as small percentage of the sale.
      For example, the buy() function in our contract could subtract, let's say 5%, before transferring the money to the seller. Likewise, we could also charge the buyer an extra 5% on top of the total amount. So if someone buys 10 NFTs at 10 ETH each, and the buyer percentage is 5%, then the payable total will be ETH 105.
      After that, we'll also take away 5% from ETH 100 (not from 105), and we transfer that ETH 95 to the seller. And that's how you make a ETH 10 profit!
      Hope this makes a bit more sense.

  • @wrb8942
    @wrb8942 2 ปีที่แล้ว

    You gained a subscriber + respect!!

  • @lobsanggyatso6280
    @lobsanggyatso6280 2 ปีที่แล้ว

    M bit confuse 26:04 why are we transfer it to contract address . Even it can be transfer to minter address . Can u explain it please

  • @cairair1011
    @cairair1011 2 ปีที่แล้ว +2

    Nice!

  • @HydronBull
    @HydronBull 2 ปีที่แล้ว

    My IERC721 token keep showing as "Undeclared Identifier". What am I missing that would fix that?

  • @44below46
    @44below46 2 ปีที่แล้ว

    Npx truffle init doesn’t work is there an alternative?

  • @TheKamieniu
    @TheKamieniu 2 ปีที่แล้ว

    Yeah. Cool one. But why all Tutorials don't have a method to fetch all Items in the Listing? What are best ways to do it? How to avoid huge Gas costs?

  • @ashirfulkamlesh5353
    @ashirfulkamlesh5353 2 ปีที่แล้ว

    I couldn't get the Installation about the Node is properly

  • @androidtechsayed201
    @androidtechsayed201 2 ปีที่แล้ว +1

    Next video pls

  • @sahab999
    @sahab999 2 ปีที่แล้ว

    How do we advertise the marketplace? Facebook Ads?

  • @abeechr
    @abeechr 2 ปีที่แล้ว +4

    Closed sea. Ha!

  • @pankajjoshi2547
    @pankajjoshi2547 2 ปีที่แล้ว

    Solidity syntax are not tough to understand , but problem begins when playing with address of deployer and participants in any project.
    Pls mk one series on how to play with address , balance ,getaddress of participants display their balance and all in remix

  • @7nkshyt368
    @7nkshyt368 2 ปีที่แล้ว

    تنصحني ب اي عشان اتعلم السوليديتي

  • @monroebayer783
    @monroebayer783 2 ปีที่แล้ว

    how to create an auction function ?

  • @pankajjoshi8292
    @pankajjoshi8292 2 ปีที่แล้ว

    Can you teach us next how to connect to frontend like html page or react. thanku

    • @husnain9778
      @husnain9778  2 ปีที่แล้ว +1

      Hope this helps 🙂 th-cam.com/video/h9PdvEDuZS8/w-d-xo.html

  • @sammafi5599
    @sammafi5599 2 ปีที่แล้ว

    Video starts from 1:12

    • @kamalsharma4866
      @kamalsharma4866 2 ปีที่แล้ว

      the starting is worth watching 😤

  • @andrewpan3047
    @andrewpan3047 2 ปีที่แล้ว

    amazing!!!!

  • @markvirchenko4619
    @markvirchenko4619 2 ปีที่แล้ว +1

    On 27:30, you say that token transfer should be done in the beginning.
    It actually doesnt matter at all, whether its in the beginning or in the end. Because its a single transaction that will completely revert if something doesnt work.
    The next concern is, you dont have to make a transfer on listing. User can continue to use their NFT while it is listed, and only when someone attempts to buy the NFT, you can make the transfer. On UI, you can emulate the buy transaction and not display buy button if it doesnt succeed.
    Many things seem to not make sense. Please comment, maybe im mistaken.

    • @markvirchenko4619
      @markvirchenko4619 2 ปีที่แล้ว

      The same thing on 30:00. Do you know what a transaction is? Its a concept where either everything is executed, or nothing.

    • @husnain9778
      @husnain9778  2 ปีที่แล้ว

      You’re absolutely right about the state not changing in case of a “revert”, but there is a distinction between a transaction reverting vs it not going as expected.
      As mentioned a couple of times in the video, we have no control over the listed token contract and can't trust how it works. As long as revert() is called by the external contract we're fine as state changes won’t apply, however, we cannot guarantee that. In this case, our test NFT is an OpenZeppelin contract that reverts on missing approval, what if this was a contract that didn't?
      By executing functions in this order we're minimising the chances of something going wrong.
      Now regarding your other point, YES WE DO need to transfer the token. The contract is depositing the token in escrow so that when someone tries to buy it, the order can be executed. If we were to do it the way you suggest, a seller could list the token, but then transfer it to someone else (or revoke our approval). And when someone makes a purchase, the token won’t be in our possession, nor we’ll have access to it. We’d be promoting listings to buyers and every time someone actually buys, the transaction fails.
      I can (somewhat) appreciate your suggestion of having sort of a dry-run before the actual sale. But then… wouldn’t you be just transferring the token before a user even buys? Everyone would be getting free NFTs?! Also, ever considered how expensive this could get, and who pays for it all?
      To correct you on your own solution, you could use something like isApproved() on the front-end to make sure the transfer is possible. But this isn’t a tutorial about UI/UX. This is an introduction to Solidity teaching people about a variety of concepts they can later use to build whatever they want.
      And although this isn’t a UX tutorial, let’s talk more about it. When you’re showing listings to your users, they expect that it will go through. Do you really want a user to come across 10 listings and every time they’ve made up their mind, the buy button is nowhere to be seen? That would be terrible design.
      You could loop through each listing, get the current owner of a token, verify it matches the listing seller’s address, and then make another call to ensure your market contract is approved to transfer it. This could be a solution, but not a very cheap nor efficient one.
      Not to forget, it would mean polluting the network with countless listings that don’t really exist 🤷🏼‍♂️
      But don’t get me wrong… I’m sure there are other solutions. I know of some better ones myself (one using an indexing solution for example), but they are definitely out of scope for this video.
      Hope this clarifies at least some of your concerns. Or maybe I’ve completely misunderstood you.
      EDIT: In case of 27:30, I think some confusion might be caused by there not being any extra checks. Doing it this way in listToken() doesn't really add any value but I find it to be a good practice to follow in general. For cases in which the external transferFrom() doesn't use revert(), we should have a check that verifies that the ownership of the token was changed.

    • @markvirchenko4619
      @markvirchenko4619 2 ปีที่แล้ว

      @@husnain9778 We are not loading the network with too many requests, because querying does not create transactions, it just looks up the blockchain for values. It does not cost anything and is not causing any load

    • @markvirchenko4619
      @markvirchenko4619 2 ปีที่แล้ว

      Regarding order. It does not matter even if the external contract does not have a revert. In such a case transaction will wrongly proceed fine, but it will do so regardless of order of operations. I.e 1. Transfer token 2. Create listing or 1. Create listing 2. Transfer token - these operations are completely independent and order changes wont have any effect, in both cases (with revert or without)

    • @markvirchenko4619
      @markvirchenko4619 2 ปีที่แล้ว

      Do you have any updates on my comments? Am I correct about this or not?

  • @alahirajeffrey
    @alahirajeffrey 2 ปีที่แล้ว

    Very good video. Wish I could give u more likes.
    Quick question: npx truffle init keeps throwing errors. I am using a windows 10 PC.
    Any ideas on how to solve it?

    • @husnain9778
      @husnain9778  2 ปีที่แล้ว

      Thanks, Alahira 🙏🏼
      Have you managed to resolve the issue yet?

    • @alahirajeffrey
      @alahirajeffrey 2 ปีที่แล้ว

      @@husnain9778 not really. I guess I would just try using hard hardhat instead

    • @husnainjaved272
      @husnainjaved272 2 ปีที่แล้ว

      @@alahirajeffrey Feel free to post the error messages here, or in the Discord server, and maybe we can find a solution. Hardhat is great too, but of course, switching over does not necessarily mean that everything will 100% work as expected.

  • @bigmac5865
    @bigmac5865 2 ปีที่แล้ว +1

    Go The Husnain .... H

  • @cairair1011
    @cairair1011 2 ปีที่แล้ว

    Do you know how I can add a commission on every transfer to go to the creator of the nfts?

    • @husnain9778
      @husnain9778  2 ปีที่แล้ว +2

      That's a really cool feature I wanted to cover but also didn't wanna make this video too long or overwhelming. I'll try to make a video on it soon 👍🏼

  • @husnain9778
    @husnain9778  2 ปีที่แล้ว

    Yes... the facecam was recorded on a potato 🥔

  • @gojic1
    @gojic1 2 ปีที่แล้ว

    First of all, great job ,really mean it. Secondly, i have problem when i try to buy nft using buy function i always get an error: Note: The called function should be payable if you send value and the value you send should be less than your current balance.

    • @husnain9778
      @husnain9778  2 ปีที่แล้ว +1

      Thanks dude. And it's easy to forget adding the "payable" modifier to the function (like shown at 19:35), and this could be the reason for the error. Can you confirm this is there?

    • @gojic1
      @gojic1 2 ปีที่แล้ว

      @@husnain9778 btw thanks for fast response 🙂

    • @gojic1
      @gojic1 2 ปีที่แล้ว

      @@husnain9778 yes i added payable, i am using remix and my button is red, meaning it is marked as payable. I changed IERC721 to ERC721 but than i tried like you with interface and the same .Can you explain about wei. I listing price as 1. then putting 1 as value when buy...maybe there is problem?

    • @husnain9778
      @husnain9778  2 ปีที่แล้ว

      ​@@gojic1 Wei is a very small unit of ETH, you can use a Wei to ETH calculator to get a better idea of the scale.
      Also, it's difficult to determine the issue without seeing the code, have you maybe tested a higher amount of Wei?

    • @gojic1
      @gojic1 2 ปีที่แล้ว

      @@husnain9778 well i find the problem...when i list nft,i put tokenId 0,but when i buy it i need to put tokenId 1...the error is so misleading..i tried both offline and with polygon mumbai test net and it works,as suppose so...thanks 😀

  • @salvadorsp5232
    @salvadorsp5232 2 ปีที่แล้ว

    Hello

  • @lloydrobinson5336
    @lloydrobinson5336 2 ปีที่แล้ว

    Hi mate do you have a personal page I can contact you on? I have a nft project I need help with and I'm in the UK 🇬🇧