'How to to prevent anyone from creating an smart contract/ NFT linking to the same URI?
Below is a min example of a smart contract that allows registering a URI to create an NFT (for ease of argument, this is highly simplified and not doesn't allow any interaction with the contract, that is no one can register their own link, etc.):
pragma solidity ^0.6.0
contract ExampleToken {
string public name = "example token"
string public uri = "http://example-link.com/123examplelink"
address public owner_of_token = 0x1234567890...
}
Except for being highly simplified, this is how we create NFTs (I am ignoring ERC standards etc.), that is we create a smart contract that allows connecting an address to a link where the file is stored (again, highly simplified, I am not using a mapping or anything).
But how is it ensured that this address truly is the owner of that linked file? Couldn't I just create a second contract that claims a different address is the owner of the same link?
Solution 1:[1]
You could create a mapping to store the URI's
mapping(string=>bool) private _usedTokenURIs;
Then write a function to query this data structure:
function tokenURIExists(string memory tokenURI) public view returns(bool){
return _usedTokenURIs[tokenURI]==true;
}
then add a require statement in your mint function
require(!tokenURIExists(tokenURI),"Token URI already exists")
- it is possible that people can use the same uri and make fake nft’s but remember people are gonna buy from reputable artists not from a random user that you dont know. You cannot prevent someone using same uri and creating a duplicate token. but this article talks about a company's system to prevent this:
The Pastel Network has developed a unique solution to provide an extra layer of assurance to collectors that guarantees the NFT is not a rip-off or a fake. Using the Pastel NFT fingerprint mechanism, creators can ensure that the authenticity of their original NFT is maintained. While Pastel verifies the authenticity and provenance using the creator’s digital signatures (like all NFT systems in use), it goes much further and assesses how rare the underlying pixel patterns of the NFTs’ data are.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
