TLDR: I would like all the NFTs to use the same token URI - an IPFS hash that contains JSON file with all the metadata.
Looking at the source: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/538b6d21b15733601f9193af5b9f662b94f16ea1/contracts/token/ERC721/ERC721.sol#L91
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0
? string(abi.encodePacked(baseURI, tokenId.toString()))
: '';
}
Looks like tokenURI
is individual for each token.
Does it make sense for many NFTs to share the same tokenURI
?
In my opinion yes.
I could be wrong?
Limited series of 100 artworks or passports. All of them can share the same token URI?
SHILL: https://docs.google.com/document/d/1bN4MpxCpEad-1PesnX9B3Lu_Sm57IEXQfHCoagYXB3M/edit?usp=sharing
(still working and editing, the JSON metadata on IPFS and tokenURI
is the current problem I'm solving)
RELATED (DYOR)
- https://docs.openzeppelin.com/contracts/4.x/api/token/erc721#IERC721Metadata
- Create an NFT and deploy to a public testnet, using Remix
- NFT tokenId in ERC721
- Where to store NFT metadata and where to set the price?
I don't want to deploy a directory of JSON files, I just prefer a sigle JSON file that is applicable for the NFTs.
STANDARD
/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension
/// @dev See https://eips.ethereum.org/EIPS/eip-721
/// Note: the ERC-165 identifier for this interface is 0x5b5e139f.
interface ERC721Metadata /* is ERC721 */ {
/// @notice A descriptive name for a collection of NFTs in this contract
function name() external view returns (string _name);
/// @notice An abbreviated name for NFTs in this contract
function symbol() external view returns (string _symbol);
/// @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 returns (string);
}
- This is the “ERC721 Metadata JSON Schema” referenced above.
{
"title": "Asset Metadata",
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Identifies the asset to which this NFT represents"
},
"description": {
"type": "string",
"description": "Describes the asset to which this NFT represents"
},
"image": {
"type": "string",
"description": "A URI pointing to a resource with mime type image/* representing the asset to which this NFT represents. Consider making any images at a width between 320 and 1080 pixels and aspect ratio between 1.91:1 and 4:5 inclusive."
}
}
}