0

I understand that one can use the tokenURI field to add the address for an endpoint that returns meta data for the given token. Let's imagine we create a unique asset with

tokenId = "1"
tokenURI = "https://api.endpoint.com/1" 

Let's say tokenId "1" refers to an asset of value $500. However, there is also a asset with tokenId "2" which is valued $2000. Let's assume there is a crypto market place that lets owners of assets trade their crypto collectibles and uses the tokenURI to receive meta data.

I understand the tokenURI can be updated.

What would hinder a holder of tokenId "1" to update his tokenURI to

tokenId = "1"
tokenURI = "https://api.endpoint.com/2" 

What hinders the market place to display the more valuable related crypto collectible? Why does it make sense to leave owners of the token with the possiblitiy to update the tokenURI?

0

Because the contract would not allow the holder to update their token URI.

The 0xcert Framework (one implementation of ERC-721) separates permissions for creating NFTs and changing their URIs.

0

The first solution I can think of is appending the variable tokenURI with the keyword constant or immutable. This would ensure that the URL of an asset would never be changed once the contract is deployed.

However, this raises a concern that you won't be able to change the URI once the contract is deployed, even in genuine cases such as you shifted your asset to a different URL address and want to update the tokenURI to point to the new address.

This problem can be solved if your contract is not escrow(ownership of contract is not renounced) and actually has a trusted contract owner. So, if your contract has a trusted contract owner, you could introduce a new function modifier such as onlyOwner, for a function that changes the tokenURI in the following manner:

address public owner;

constructor() {
  owner = msg.sender;
}

modifier onlyOwner() {
  require(msg.sender == owner);
  _;
}

function changeAssetURI(string memory newURI) private onlyOwner {
  tokenURI = newURI;
}

If all the above points do not help your specific use case, then the only viable solution I can think of is using a trusted Oracle (such as ChainLink) to query the tokenURI of a given tokenID from a public API. This would require you to first create a public API that returns tokenURI for specified tokenId. Since the API would be public, it would deter miscreants from scamming the customers in an auction.

Hope it helps. Thank you.

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.