How to store NFT metadata URI in ERC1155 Solidity 🧐

Поделиться
HTML-код
  • Опубликовано: 24 июл 2024
  • Learn how to manage your metadata URIs. After watching this video you will know how to make your URIs immutable or allow to change them under special circumstances.
    0:00:00 Default URI in ERC1155
    0:03:40 URI supported by OpenSea
    0:07:00 Immutable metadata
    0:12:00 Set URI per each token
    0:15:00 Control metadata
    Check out my open email course: bit.ly/web3starter
    Links:
    docs.openzeppelin.com/contrac...
    nft.storage/
    car.ipfs.io/
    arweave.org/
    Code:
    gist.github.com/Chmarusso/3a8...
    #nft #solidity #smartcontracts
    Blog: fullstak.pl/
    Instagram: / fullstak_pl
    Discord: / discord
    Twitter: / artichmaro
  • НаукаНаука

Комментарии • 94

  • @chloe.t9693
    @chloe.t9693 2 года назад +2

    this is awesome! thank you so much for making this video :) so many videos on ERC721 but hard to find any dev-related ones for 1155. thanks again!

  • @farhanqureshi8811
    @farhanqureshi8811 2 года назад +5

    Exactly what I was looking for. The fact that you sensed a problem that exists and came up with a solution and then shared to the outside world, its just too generous. Many Thanks.

    • @ArturChmaro
      @ArturChmaro  2 года назад

      Glad it helped you Farhan!

    • @Phas0ruk
      @Phas0ruk Год назад

      agree, very useful. Thanks. There's no Opensea 1155 tutorial which doesn't help.

  • @mariofernandez3601
    @mariofernandez3601 2 года назад +5

    Thanks for solving my hundred questions in 18 minutes, nice tutorial :)

  • @avourofficial
    @avourofficial 2 года назад +7

    Honestly, you're a really good dev, I've been searching for ways, to uniquely upload uri metadata for erc1155, you just solved my issues in a few minutes. keep it up bro

    • @ArturChmaro
      @ArturChmaro  2 года назад +1

      Glad I could help!

    • @layermaker3139
      @layermaker3139 2 года назад

      Hi Avour I am struggling with some of the basic concepts with in this video. I was wondering if I could ask you a few questions regarding some of the aspects covered in this video?

    • @avourofficial
      @avourofficial 2 года назад

      @@layermaker3139 sure mate, what's the issue

  • @JohnDoe-ch7bo
    @JohnDoe-ch7bo 2 года назад

    The only thing I could currently ask for is verifying support for ERC165 and testing for it. Otherwise, love your videos, they're concise and very helpful

    • @ArturChmaro
      @ArturChmaro  2 года назад

      Thanks for the info! I will try to cover that in future vids.

  • @DustVoltrage
    @DustVoltrage 11 месяцев назад

    That was SO HELPFUL !
    Thanks a lot man, very clear and useful =)

  • @taniapapasotiriou
    @taniapapasotiriou 2 года назад

    thank you for the clarity of this presentation

  • @yeyerock
    @yeyerock 2 года назад

    Thank you bro, i was loking for this and it helped me a lot

  • @geeked-outbasketball765
    @geeked-outbasketball765 2 года назад

    Awesome video -- very clear explanation!

  • @raybourne3564
    @raybourne3564 2 года назад

    Hey Artur I'm really grateful for your content, I'm working on my own erc1155 token to use with an NFT collection I'm working on and I'm stuck in exactly on the URI metadata mine doesn't have the default because when copied the code from Openzeppelin I had left the URI blank since I didn't know what to put in their.....how do I fix it

  • @sunya7a
    @sunya7a 2 года назад

    Very nice. Thanks

  • @mjmj007a
    @mjmj007a 2 года назад

    Good video and Thank you...

  • @manolii344
    @manolii344 Год назад

    Cool, thanks!

  • @cosmictryo1819
    @cosmictryo1819 2 года назад

    Awesome tutorial

  • @DDimka100
    @DDimka100 2 года назад

    Thanks a lot, Artur

  • @johnsnow1279
    @johnsnow1279 2 года назад +2

    Did you forget to pad the setTokenURI because ERC1155 standard says it must be 64 characters? Can you show how you would implement that. Thanks.

  • @CricketUniverseicc
    @CricketUniverseicc 2 года назад +3

    Hi Artur,
    I am getting warning by using change uri function: Warning: This declaration shadows an existing declaration.
    When I ignore the warning and deploy the smart contract, the metadata is not visible on NFTs. Can you please help?

  • @ArturChmaro
    @ArturChmaro  2 года назад

    🛠 Web3 Starter for JS Devs (email course): bit.ly/web3starter

  • @jb3229
    @jb3229 2 года назад

    thanks for the video

  • @zachz6620
    @zachz6620 Год назад

    Incredible Video. Thanks for sharing. One thing that is confusing is how would you create a smart contract that does not allow users to mint from a set of pre-loaded NFT's but rather mint their own nfts/tokens. Do you just remove everything from the constructor and in ERC155 you put no string? So in the constructor you just have.... ERC1155 " ". Like you just have quotes with an empty string? In other words nothing goes in the quotes? Instead users can just use the mint function and setToken Uri to create their own NFT's? Would love to see a video on creating these contracts without minting a set of pre-set nfts/tokens but rather just allowing the user to mint their own nft's and set their own meta data.

  • @Nizznightlife
    @Nizznightlife 2 года назад

    is there a reason why you deleted the string abi encode ? How to display on opensea with the current code? Thx

  • @RootsterAnon
    @RootsterAnon 2 года назад +3

    For anyone who is currious why is there Unnamed collection - hash. You need to add few variables
    "
    // Contract name
    string public name;
    // Contract symbol
    string public symbol;
    "
    into your .sol file and set them up in the constructor.

    • @ArturChmaro
      @ArturChmaro  2 года назад

      Thanks for adding this up! :) I should have been told about it in the video

    • @marcosarzina1102
      @marcosarzina1102 2 года назад

      IS THERE A NEED TO SPECIFY THE NAME AND SYMBOL IF The ERC1155 standard interface has a URI (Uniform Resource Identifier) that can point to a file where you can specify all the characteristics of the token (name, symbol, description, size, color or whatever you want) ?

  • @DPortal17
    @DPortal17 2 года назад

    Excellent content Artur. For some reason I am not able to join your Discord, msg says "Unable to accept invite" ?

  • @wenrays2728
    @wenrays2728 2 года назад

    I am curious to be your student please support us with such.great knowledge

  • @istiaque_ahmed
    @istiaque_ahmed 2 года назад

    This was very helpful. Could you please tell me in which site you uploaded you images?

  • @danal9305
    @danal9305 2 года назад

    Hi Artur, thanks for this tutorial. Will this IPFS link work straight forward as entered in the .sol or we have to connect through API? I tried using the same link as you have done but, I'm seeing any images populated in the NFT it's blank and sometimes, only the first NFT is minted with images and meta tags and the rest are blank. Any thoughts?

    • @ArturChmaro
      @ArturChmaro  2 года назад

      I've just uploaded couple images for demonstration. If you want to upload more pictures you have to use service like Piniata or nft.storage

  • @prince5105
    @prince5105 Год назад

    does this apply with erc721?

  • @peteratef34
    @peteratef34 2 года назад

    Great video! I think batching setTokenUri to set multiple URIs for different tokens can save some fees.

    • @ArturChmaro
      @ArturChmaro  2 года назад

      That's right, batch functions always make sense to save money on fees

  • @timnancy7639
    @timnancy7639 2 года назад +1

    Great video Artur. How would one update 100x setTokenUri efficiently? When I tested this, I called it in a for loop and Metamask would prompt me to sign every iteration individually. :(

    • @AlbertoVasquez1
      @AlbertoVasquez1 Год назад

      You would need to have a batchSetUri function public in your smart contract

  • @dr.psycho5606
    @dr.psycho5606 2 года назад +1

    If my token id is 0 how am i supposed to fill 64 zeroes in the {id} ? when i try to do like you explained i get 0.json which doesn't work with ERC1155 because the file name needs to be padded with zeroes

    • @ArturChmaro
      @ArturChmaro  2 года назад

      we it has to be padded with zeros? Works for me without zeros

  • @0xMowgli
    @0xMowgli 2 года назад

    issue solved thnx

  • @itsanishjain
    @itsanishjain 2 года назад

    I am running the exact code

  • @frozenzaid9863
    @frozenzaid9863 2 года назад

    one question, have you tried to deploy the ERD1155 contract on BSC nft marketplace?
    is the contract same as when you deploy on opensea ?

  • @shivamdas9895
    @shivamdas9895 2 года назад

    But for 3D model how to use the metadata standard ? Shall we replace image url with model url ?

    • @ArturChmaro
      @ArturChmaro  2 года назад +1

      You have animation_url attribute, there you can provide link to your glb. Otherwise you can just add customized attribute and that's it

  • @itsanishjain
    @itsanishjain 2 года назад

    Hey this is not working for me, Means Metadata is not showing on Opensea

  • @olivertaborda9801
    @olivertaborda9801 2 года назад

    Hello friend, how are you? great your video! one question, can I put the private BaseUri? I don't want them to see my NFT before minting, is that valid?

    • @ArturChmaro
      @ArturChmaro  2 года назад +1

      You can control which URI is returned. Just introduce internal state in the contract and depending on it's value return different (or none) URI

    • @olivertaborda9801
      @olivertaborda9801 2 года назад

      @@ArturChmaro interesting friend... I understand, thank you very much

  • @nikhilkadam9255
    @nikhilkadam9255 2 года назад

    If NFT builds on Opensea smart contract, is it possible to deploy it's own contact smart

    • @ArturChmaro
      @ArturChmaro  2 года назад

      Not sure I got you right, but you may mint on OpenSea contracts or just go with your own.

  • @evdark-7638
    @evdark-7638 2 года назад +1

    after this it will show Metadata: Frozen on opensea ?

    • @ArturChmaro
      @ArturChmaro  2 года назад +1

      I think frozen is just extra feature offered by OpenSea. After clicking it they are putting meta data to IPFS and just marking collection as frozen on their side.

  • @HabibLawal
    @HabibLawal 2 года назад

    Hey Artur do you think it is worth adding an error check to this code for the case of someone calling the uri function for a tokenID that has not yet had a tokenURI set for it.

    • @ArturChmaro
      @ArturChmaro  2 года назад +1

      Sure, that would be good idea to add safe check for that :)

    • @layermaker3139
      @layermaker3139 2 года назад

      Hi Habib I am struggling with some of the basic concepts with in this video. I was wondering if I could ask you a few questions regarding some of the aspects covered in this video? You seem to have a very good understanding of it

    • @HabibLawal
      @HabibLawal 2 года назад

      @@layermaker3139 yeah sure

    • @layermaker3139
      @layermaker3139 2 года назад

      @@HabibLawal Thank you Habib do you have a email i could send you some questions to?

    • @AlbertoVasquez1
      @AlbertoVasquez1 Год назад

      @@layermaker3139 I'm assuming he meant you can ask here

  • @DustVoltrage
    @DustVoltrage 11 месяцев назад

    Just one question !
    I'd like my GameItems to be upgradable, and for this I need a way to make distinction between the different "instances" of the same tokenID...
    I've been working on it for hours but I can't got it to work =(
    Would be a very advanced and useful tutorial... don't you think ? :D

    • @ArturChmaro
      @ArturChmaro  11 месяцев назад +1

      Not possible ... you cannot distinct between multiple instances of the same token id. Just mint another token with same metadata

    • @DustVoltrage
      @DustVoltrage 11 месяцев назад

      @@ArturChmaro That's a real shame, and sounds almost like a deal breaker for any rpg like game :/
      Also I don't really understand how the network could transfer one address's token to another address without being able to have a reference to this token !
      Or is it like a "fake transfer" and the method actually just decrease the balance of the sender and increase the balance of the receiver for this tokenID ? Would make sense...
      I suppose the only workaround for my upgrade system then would be to have separate tokenID for the different levels of weapons and burn the token to mint the upgraded one...
      But in the front end (unity) it seems difficult to know which token replaced which one (in inventory for instance...)
      Have you thought about this sort of mechanism yourself ?

    • @ArturChmaro
      @ArturChmaro  11 месяцев назад

      @@DustVoltrage If you want to have upgrades per item I think what you really have to do is mint "Firesword" with amount of 1 and just transfer it to the player. Then player can update Firesword#1 to "Firesword Enhanced #1".
      However if you want to mint Firesword#2 that has amount of 200 then you can just track ownerships of that very specific item. If you upgrade that item then all the holders would have updated version.

    • @DustVoltrage
      @DustVoltrage 11 месяцев назад

      @@ArturChmaro But this would be hell to create the item database this way.
      What about =
      - having a struct for my weapon "class" that i can declare as the owner, i would create as many as i want
      - then user would pass a specific weapon to the mint function
      - mint function would create automatically a new tokenID so each weapon minted has its own tokeniD
      What do you think ? I would still need each token to keep the struct associated with the token though

  • @genwav
    @genwav Год назад

    I get metadata unavailable with this solution..

  • @mayurpatel6657
    @mayurpatel6657 2 года назад

    I have one question, i am minting 2000 nft using ERC1155 but in batch of 500, what if one of the batch get failed to mint, does that mint all 500 nfts from 501 to 1000 will fail to mint of only few will mint and i will get error for remaining nfts that failed? do let me know the answer .

    • @ArturChmaro
      @ArturChmaro  2 года назад

      Whole batch will fail

    • @mayurpatel6657
      @mayurpatel6657 2 года назад

      @@ArturChmaro thank you so much

    • @mayurpatel6657
      @mayurpatel6657 2 года назад

      @@ArturChmaro can you please provide any reference link where this is mentioned that it will fail whole batch? it will be very helpful to explain to my team.

    • @ArturChmaro
      @ArturChmaro  2 года назад

      @@mayurpatel6657 you can check it yourself on the testnet ;)

  • @uguur
    @uguur 2 года назад

    How can i create multiple nft in one contract ?

    • @ArturChmaro
      @ArturChmaro  2 года назад

      just expose mint function ;)

    • @uguur
      @uguur 2 года назад

      @@ArturChmaro but how :D because there should be rare properties common properties like that so if you record another video this will be perfect :D

  • @Cristian77595
    @Cristian77595 2 года назад

    How to get all tokens of owner?

    • @ArturChmaro
      @ArturChmaro  2 года назад +1

      I see multiple solutions here:
      1. Customize contract so it tracks token ids owned by certain ppl.
      2. Store that data centralized way
      3. Fetch all events emitted from contract and parse them

    • @Cristian77595
      @Cristian77595 2 года назад +1

      @@ArturChmaro Do you have an example on option 1?

  • @decentralizedfusion205
    @decentralizedfusion205 2 года назад +2

    Loving the crypto insight, I just made my own video, share the love ;)/