This is very juvenile question but can someone explain the basic of what the tokenURI is in ERC721 and the workflow of it with respect to minting? Is the tokenURI the address that the minter puts in when he mints a token if its on the internet/ipfs. For example if you go to OpenSea and you mint a token it will ask you to either upload your artwork/NFT from your computer or ask you to put in the tokenURI (location on IPFS), and then it will mint the token. So the tokenURI is essentially the location on IPFS that your NFT was pulled from? Correct or all jacked up?
Yeah you're more or less correct. One detail is that tokenURI is not directly the image or media for the NFT, it is a JSON file that describes the NFT and among other things will include another URI where the media is hosted.
Okay thank you for the response. So putting in the tokenURI when minting is optional correct? For example if i wanted to mint a token, I would only put in the tokenURI in if I had it on IPFS right? The tokenURI would be the address on IPFS right?
On the other hand , if i did not have it on the IPFS and only had the NFT/artwork on my computers harddrive, what happens when I mint? Will it create a tokenURI for me?
Your questions sound specific to OpenSea so I don't know the answer.
I've never used Open Sea or any NFT websites. Have never even been to those websites or created an NFT. I was just wanting to know for the purpose of coding my own NFT Smart Contracts in conjunction with Open Zep libraries. Just trying to understand the workflow better (especially from the perspective of the user/minter) and understand how tokenURI works in the contracts. For example, should every mint function contain an input/argument that takes the tokenURI if I want to be ERC721 compliant. Or is the tokenURI optional?
All good though i will continue to look for some resources to get a better understanding. I notice things changed a bit after 0.8.0 with respect to using the tokenURI functions which is also whats tripping me up. If anyone else here reading through can explain the basics of how the tokenURI function are working would appreciate to hear.
1 - The art or image must be hosted at some address.
Better in an IPFS that will always be there and cannot be changed.
2 - When an art or image is registered (minted) in a blockchain, the concept of NFT arises. An immutable record and an immutable storage place.
3 - TokenUrI is from the ERC721 standard and in the Open Zeppelin libraries it is defined in the IERC721Metadata-tokenURI interface
4 - Your contract take inherit from ERC721 which in turn implements the IERC721Metadata-tokenURI interface.
5 - You will override this function by putting your own functionality, but you should know that to a marketplace (OpenSea) this must be a place where the metadata of the art or image is.
Looks like so:
{
"name": "Name of collection #{i}",
"description": "Your Comment",
"image": "ipfs://QmVmSfUfY36NtjgR621FhWQUwrsDt9Uif2ymvpt5rA4dEx",
"creator": "Your Name",
"edition:" :{i}
}
Where {i} is the consecutive of the collection.
6 - That is, the URI token response must point to where this metadata is. Which I also recommend it be hosted on IPFS.