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);



2 Answers 2


See: https://eips.ethereum.org/EIPS/eip-721#simple-summary

/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension
/// @dev See https://eips.ethereum.org/EIPS/eip-721
///  Note: the ERC-165 identifier for this interface is 0x5b5e139f.
interface ERC721Metadata /* is ERC721 */ {
    /// @notice A descriptive name for a collection of NFTs in this contract
    function name() external view returns (string _name);

    /// @notice An abbreviated name for NFTs in this contract
    function symbol() external view returns (string _symbol);

    /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.
    /// @dev Throws if `_tokenId` is not a valid NFT. URIs are defined in RFC
    ///  3986. The URI may point to a JSON file that conforms to the "ERC721
    ///  Metadata JSON Schema".
    function tokenURI(uint256 _tokenId) external view returns (string);

You can use extra fields for name and symbol.

  • This is a per-contract name, not a per-token name. I believe the asker is seeking the latter. Jul 28, 2021 at 14:14

I understand that you are looking to have a contract-enforced way to specify that the metadata will include a certain name.

Of course you will not achieve this goal if the contract allows arbitrary URLs linking to arbitrary JSON which can have any name set.

Here are some options.

  1. Give up. Do not put the name in the ERC721Metadata, instead, create a proprietary tokenName(uint256) function which you manage separately.
  2. Use ERC2477 (DRAFT). This allows you to have some control over the metadata to ensure the name is as you want it. Note that this will require you to implement a zero-knowledge proof or a JSON parser on-chain which validates the new metadata.
  3. Use 0xcert Framework. The 0xcert framework is specifically designed to provide metadata integrity for ERC-721 tokens, it uses a different hashing technique (Merkle tree) which is compatible with your use case. But it requires you to use the same schema across metadata versions.

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.