How to code this NFT 721 or 1155 ? Also an IPFS question

Hey there.

So for the purpose of the game my wife and I have been working on and which has a lot of assets, I need to decide if some assets will be erc721 rather than be 1155.

Most assets which are repetitive will be erc1155 tokens, but I do have a small problem: One category of such assets are character who are each different physically one from the other, so while they represent the same type of character, they are each different visually and as I have too many of them: over 100k such pieces (all generated from the inheritance of several body parts from parents and going through all combinations using a script that creates pngs from the originals combinations etc.)

So my dillema is : If I declared them as erc1155, I could just say I have 100k characters and my game works still, but that would not do them service as far as the uniqueness they already possess, especially perhaps for after market sales etc. since they look different, and frankly my wife’s art is usually appreciated so they may have some value , but again for the purposes of the game’s mechanics, it is not a huge issue, but for the value/uniqueness of the nft perhaps.

So the question is:

  1. what’s the best way to deal with this ? I thought about perhaps using both definitions for tracking the same asset : use ERC721 to keep track of the unique piece and use at the same time an ERC1155 definition for tracking count, but this seems redundant and a waste of space.

  2. I wrote/am writing a small script to generate all the different images for the different characters ( which are unique, but over 100k of them !! ). I could go ahead and store them in ipfs, but again this seems like a lot of space, espcially that for the game’s usage I’d have no idea how to track which is which, unless I could store the filenames in an outside json file , with id pointers for example of 1 2 3 4 … 100k pointing to the correct filename on ipfs . is that the best way to do this ? I am definitely sure there has got to be a better way and would love your insights.

thanks

  • The characters sound similar in concept to Cryptokitties which are ERC721. Each kitty has it’s own DNA which defines how it looks. Could do something similar. There are millions of CryptoKitties. See the contract code here (https://etherscan.io/address/0x06012c8cf97bead5deae237070f9587f8e7a266d#code)
    • Can create a struct that defines the “DNA” or attributes of the char then store that on chain
    • Or can put the attributes in meta data using JSON, store it in IPFS, then use the IPFS hash as the token URI (like on OpenSea)
  • You can think of ERC1155 as a collection of ERC20 token items. Each item in an ERC1155 can be unique, but every instance of that item is identical and interchangeable. A good example would be a healing potion in an RPG. There may be many kinds of healing potions but every “minor healing potion” is the same.

Be sure to check out the ERC721 and ERC1155 implementations on Openzepplin and use those if you can. Inherit from their contracts then add what you need.

2 Likes

thanks for your help and insight. I am going to check out a bit more the kitties contract, and yes, I was planning to definitely be using Openzepplin .

1 Like