-1

I want to mint nft with a custom structure :

  • 1 ipfs link to a png image
  • 1 ipfs link to a xml file
  • 1 ipfs link to binary file
  • 10 key/value pair

How can i do that ? can i use erc721 or use other one ?

thanks.

1 Answer 1

1

You can use ERC721. You'd have 3 ways to go about it I think:

Create functions like tokenURI that would return the wanted address of the file.

OR

Create a structure that stores those info. And store it in a mapping. Something like:

Struct additionalInfo{
 string xml;
 string bin;
 ....
}

mapping(uint=>additionalInfo) public tokenInfos;  ///tokenId to additionalInfos

Last way is like Casareafer said to do it offChain and simple intergrate this data in the metadata file.

Either onChain or offChain you'd have to write function in the front that can access this.

7
  • additionalInfo seems to be the good way but where i put it in my nft ? _mint(signer,tokenId); _setTokenURI(tokenId,uri); Because the mint have just these 2 methods
    – Cryptopowa
    Commented Nov 24, 2022 at 10:09
  • 1
    this is valid, however I'd suggest this to go on the Metadata of the token since storing information in the blockchain is not cheap; I'd create a Metadata json file, upload it to IPFS through any platform and then store the IPFS CID in the contract
    – Casareafer
    Commented Nov 24, 2022 at 10:55
  • docs.opensea.io/docs/metadata-standards
    – Casareafer
    Commented Nov 24, 2022 at 10:56
  • If you wanted to do it onChain you'd have to create those functions (that would return the metadata address) yourself.
    – Torof
    Commented Nov 24, 2022 at 11:21
  • @Torof but the metadata of a NFT are only : Name, Symbol and tokenURI. How to have additionalInfo inside and get/set this new data ?
    – Cryptopowa
    Commented Nov 24, 2022 at 11:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.