Seems tokenURI always returns a URL, so why the name choice?
1 Answer
The name "tokenURI" refers to the Uniform Resource Identifier (URI) that represents the metadata associated with a non-fungible token (NFT). While the URI may often be a URL (Uniform Resource Locator), which is a type of URI that specifies the location of a resource on the internet, it could also be a different type of URI such as a Uniform Resource Name (URN), which is a persistent identifier that doesn't necessarily have a location associated with it.
The reason the name "tokenURI" was chosen is that it reflects the fact that the URI provides a unique identifier for the metadata associated with a particular token. This metadata may include information such as the name of the token, a description, the creator, and any other relevant data. By providing a standardized way to access this metadata, the URI helps to ensure that NFTs are interoperable and can be easily integrated into a wide range of applications and platforms.
Seems like URI returns URL, which contains URI 😊
In the context of NFTs, the difference between URL and URI is related to how they are used to access the metadata associated with an NFT.
A URI (Uniform Resource Identifier) is used to identify the metadata associated with an NFT, which typically includes information such as the name, description, and image of the NFT. This metadata can be stored on a centralized server or on a decentralized storage system such as IPFS (InterPlanetary File System).
A URL (Uniform Resource Locator) is a type of URI that specifies the location of a resource on the internet. In the case of NFTs, a URL might be used to access the metadata associated with an NFT that is stored on a centralized server. For example, a URL might be used to access the metadata associated with an NFT that is listed on a marketplace such as OpenSea or Rarible.
However, it's important to note that not all NFT metadata is accessed using a URL. In some cases, the metadata might be accessed using a different type of URI such as a URN (Uniform Resource Name), which provides a persistent identifier for the metadata without specifying its location.
So, in summary: a URI is used to identify the metadata associated with an NFT, while a URL is a type of URI that specifies the location of a resource on the internet. While URLs can be used to access NFT metadata stored on centralized servers, other types of URIs such as URNs might be used to access metadata stored on decentralized systems like IPFS.
Here's an example of an NFT URI: ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4c7mcinnlbmnxahy/
In this example, ipfs:// is a protocol that is used to access content stored on the IPFS (InterPlanetary File System) network. The rest of the URI bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4c7mcinnlbmnxahy/ is a content identifier that specifies the location of the metadata associated with an NFT.
The metadata returned by the URI might look something like this:
{
"name": "Example NFT",
"description": "This is an example NFT",
"image": "ipfs://bafkreihis72ex26a72tklrmuw6gmsc7v26xunxgrbjgjqhnbifjydnqhry/example-nft.png",
"attributes": [
{
"trait_type": "Color",
"value": "Blue"
},
{
"trait_type": "Size",
"value": "Medium"
}
]
}
This metadata includes information such as the name and description of the NFT, an IPFS URI associated with the image of the NFT, and some attributes that describe the NFT in more detail. The metadata is typically stored off-chain and referenced using the URI, which helps to keep the blockchain itself lightweight and efficient.
-
1Maybe IPFS URLs should be called URNs since they identify the content but not which server it is on. Anyone can host the file and a DHT lookup finds the server Mar 24 at 22:32