0

Over the last few days (while following a tutorial) I made a web app where I could make a NFT out of a color(e.g. #FFFFFF), so my question is if a client could upload a picture to my web app how would I mint that picture.

What exactly am I minting and where would I store that picture.

(I am a beginner so go easy)

1 Answer 1

1

You don’t mint “the picture”. You mint a token, i.e. you Transfer ownership of a new tokenId (e.g. 123) in your contract from nobody to your user. That’s all there is to minting an NFT.

Now, if your (let us say, ERC-721) contract goes even further and implements the ERC721Metadata extension, it will be possible to query your contract for information about a particular tokenID on your contract, via tokenURI(tokenID). So calling on your contract e.g. tokenURI(123) would return a URI identifying a JSON file somewhere that provides more info about token 123 on your contract. The ERC-721 standard specifies that the JSON file should include an image field, which is:

A URI pointing to a resource with mime type image/* representing the asset to which this NFT represents.

This is where the picture comes into the… picture.

So to mint a user's picture, you need to:

  1. Upload the picture somewhere (to a website or to IPFS)
  2. Upload somewhere (to a website or to IPFS) a JSON file with image identifying the picture in Step 1
  3. Update your contract so that when queried for tokenURI(123), it will return a URI identifying the JSON file in Step 2

For Step 1 and 2 you could integrate your web app with a service like nft.storage.

P.S. Using data: URIs you could also store or generate the JSON and/or the image in the contract itself, but that might be more complicated to achieve, so let’s limit the scope of this answer to the more usual method described above.

1
  • I am more interested in the P.S. part (data:)
    – MehmedB
    Apr 12, 2022 at 17:48

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.