mappingblockchainsoliditysmartcontractserc721

Alternatives to mapping in Solidity? or map data with another?


I know that the question may sound strange but... are there alternatives for mapping in Solidity?

Let me explain...

The thing is, I have to know who has the ERC721, it's like a dao, "you can't enter to a page if you don't have the Token", what my program does is a mint function of the ERC721, the id of the token increases so that everyone can have one, so knowing who owns the token is not possible by using the id, since it changes. They told me that I could use mapping and map who minted, it worked! but not completely since I needed everyone to be able to see who has it (who is stored in the mapping), is there any other alternative for this? or you can use mapping but see all the stored data(users that own the token)?

Also, forgot to mention that it can't be done with ERC1155:)

Thank you in advance🙃


Solution

  • The ERC721 standard defines a balanceOf(address) function that is supposed to return a number of tokens that the address owns.

    Example:

    You can use the returned value as an authorization scheme for your web app, allowing login for users who own at least one token (non-specific, any ID) of the collection.