1

If I wanted to create an NFT that contains the Username of a person to prove their address ownership, what is the best practices or suggested ways to enforce that no 2 copies of that NFT can have the exact same Username meta data?

Example meta data: "name": "bob"

Only 1 NFT instance could ever have the name "bob". If another was attempted to be created, it should fail to be created due to "bob" already exists as a name in an existing NFT.

Is there a particular NFT standard this should follow such as 721 or 1155?

Or is this something that can only be controlled centrally by the code that is allowed to mint new NFTs? If centrally only, is there is a best practices way to look up all existing NFT data?

1

You can keep a list of the names you have used when you create new NFT instances. E.g.:

mapping(string => uint256) public userNames;  // user name => token ID

Then, whenever you want to create a new NFT, you require that the name hasn't been used before:

function addNFT(string memory _name, uint256 _id) external {
    require(userNames[_name] == 0, 'Name already exists');
    userNames[_name] = _id;
    // create NFT
}

If using this function, make sure the first NFT has the ID starting with 1 or higher.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.