What data does an NFT actually store?

I’m building an NFT marketplace using Solidity and I’m basing it on OpenZeppelin’s ERC-721 contract. My NFTs include five attributes: an id, an image (represented by an IPFS hash), a description, a collection label, and the creator’s address.

I store these details in a struct that exists outside of the ERC-721 contract. This setup makes me wonder what the NFT actually contains. Am I implementing this correctly, or should the data be managed differently?

Here’s a revised version of my code:

contract NFTMarket is ERC721Full {
  struct TokenData {
    uint256 id;
    string ipfsHash;
    string desc;
    string collection;
    address creator;
  }

  TokenData[] public tokens;

  function mint(string memory _hash, string memory _desc, string memory _collection) public {
    uint256 newId = tokens.length;
    tokens.push(TokenData(newId, _hash, _desc, _collection, msg.sender));
    _mint(msg.sender, newId);
  }
}

Is this a sound approach? Any suggestions for improvement are welcome, as I’m just starting in Ethereum development.

hey jade75! i’m curious about ur nft project. it sounds cool! have u thought about how ur storing the data? i’ve heard that putting everything on-chain can get super expensive with gas fees. maybe u could keep just the important stuff like the id and ipfs hash on-chain, and put the rest somewhere else? what do u think about that? also, i’m wondering how ur handling the tokenURI function - that’s pretty important for erc721 right? oh and have u considered using events to track when nfts are minted or transferred? that could be really useful for ur marketplace. what features are u most excited about building next?

Your approach is generally sound, but there are a few considerations to keep in mind. The ERC-721 standard itself doesn’t specify what data should be stored on-chain, so using a separate struct to manage additional metadata is a common practice. However, storing large data sets on-chain can be expensive. It may be beneficial to store extended metadata off-chain and only retain a reference (such as a URI) on-chain, often implemented via the tokenURI function. Also, consider gas costs when minting and ensure full ERC-721 compliance by implementing necessary functions like tokenURI.

ur approach is ok, but consider gas costs. storing all that data on-chain can get pricey. maybe keep just the IPFS hash on-chain and put the rest in metadata? that’s how many projects do it. also make sure u implement tokenURI() for full ERC721 compliance. good luck with ur project!