I have a ERC721 token and the TokenURI gets set to a IPFS JSON link. The JSON contains metadata such as name, color, image ect about the NFT.
The problem is I have a function which allows the TokenURI to be updated, but how can I prevent the 'name' field being edited?
Is there another way to just store the 'name' metadata? maybe somewhere in the ERC721 contract?
Heres my contract:
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
import "github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.4/contracts/token/ERC721/ERC721.sol";
contract SampleNFTContract is ERC721 {
constructor () public ERC721 ("NFTTest1", "NFT1"){
}
// mint nft
function createNFT(uint256 tokenID, string memory ipfsLink) external {
_safeMint(msg.sender, tokenID);
_setTokenURI(tokenID, ipfsLink);
}
// update ipfsLink
function updateURL(uint256 tokenID, string memory ipfsLink) external {
// check if owner
require(_isApprovedOrOwner(_msgSender(), tokenID), "Only owner can update");
_setTokenURI(tokenID, ipfsLink);
}
}