Hello,
in a smart contract based on ERC721, is there a way to have different base URIs for different tokens? It seems to me that this is not possible and not intended, but I would like to be sure.
Best Regards,
Marc
Hello,
in a smart contract based on ERC721, is there a way to have different base URIs for different tokens? It seems to me that this is not possible and not intended, but I would like to be sure.
Best Regards,
Marc
Hey George! You can define your own tokenURI
function, so you can theoretically make each each tokenId
have a different baseURI
if you wanted. You could even make them dynamic, but that would be a peculiar use case (for example, returning something depending on block.timestamp
).
I think it fell out of fashion, but OZ's ERC721
use to ship with something like this:
/**
* @dev Sets `_tokenURI` as the tokenURI of `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual {
require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token");
_tokenURIs[tokenId] = _tokenURI;
}
Looks like there is more discussion here.
Hello LostArchitect,
thanks for your answer. The link to the other discussion was very helpful!
Cheers,
Marc