3

Regarding the metadata URI extension - I don't think it should be required that each token ID has an individual metadata URI. I think there should be a globalTokenURI state variable that can be returned from tokenURI(). If it's known that each token will have the same token URI then if the token URI was ever updated and you had 1,000 tokens you would need to loop through each token and update the token URI. That doesn't make sense if they will all be the same. I think the tokenURI() function should optionally be allowed to take a token ID, but if there are no arguments required then it should return a global URI. I'm proposing:

function globalTokenURI() public view returns (string) {
  return _globalTokenURI;
}

function modifyGlobalTokenURI(string _tokenURI) public onlyManager {
  _globalTokenURI = _tokenURI;
}

thoughts?

1

Use string concatenation and a base URL.

Here is the relevant code snippet from Su Squares:

/// @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
    mustBeValidToken(_tokenId)
    returns (string _tokenURI)
{
    _tokenURI = "https://tenthousandsu.com/erc721/00000.json";
    bytes memory _tokenURIBytes = bytes(_tokenURI);
    _tokenURIBytes[33] = byte(48+(_tokenId / 10000) % 10);
    _tokenURIBytes[34] = byte(48+(_tokenId / 1000) % 10);
    _tokenURIBytes[35] = byte(48+(_tokenId / 100) % 10);
    _tokenURIBytes[36] = byte(48+(_tokenId / 10) % 10);
    _tokenURIBytes[37] = byte(48+(_tokenId / 1) % 10);

}

https://github.com/fulldecent/su-squares-bounty/blob/master/contracts/SuNFT.sol#L225-L239

In my case, I'm using _tokenURI with a hard-coded string. I'll be honest, maybe that was not the best choice. But you are welcome to use this approach to make URIs which can be quickly change in batch.

|improve this answer|||||

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.