# How to have custom uri for each token type in ERC1155

**URL:** <https://forum.openzeppelin.com/t/how-to-have-custom-uri-for-each-token-type-in-erc1155/16752>\
**Category:** Contracts\
**Tags:** erc1155\
**Created:** [October 10, 2021, 9:42am UTC](https://forum.openzeppelin.com/t/how-to-have-custom-uri-for-each-token-type-in-erc1155/16752 "2021-10-10T09:42:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![incrypto32](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/incrypto32/32/9461_2.png) [@incrypto32](https://forum.openzeppelin.com/u/incrypto32)\
**Post date:** [October 10, 2021, 9:42am UTC](https://forum.openzeppelin.com/t/how-to-have-custom-uri-for-each-token-type-in-erc1155/16752/1 "2021-10-10T09:42:57Z")

</div>

The ERC1155 standard recommends using a single URL as the base metadata URL. And the clients need to replace `{id}` in the URL to get the desired metadata for a particular `tokenType` with its `id`.  
Is there a way to have a separate URL for each token so that we can use IPFS to store the metadata without the need for a centralized metadata server (even if that's redirecting to an IPFS hash).

---

<div class="post-metadata">

**Author:** ![frangio](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/frangio/32/15251_2.png) [@frangio](https://forum.openzeppelin.com/u/frangio)\
**Post date:** [October 14, 2021, 9:50pm UTC](https://forum.openzeppelin.com/t/how-to-have-custom-uri-for-each-token-type-in-erc1155/16752/2 "2021-10-14T21:50:43Z")

</div>

ERC1155 with `{id}` doesn't require a centralized metadata server. See this discussion about `baseURI` in ERC721:

> [@Why doesn't OpenZeppelin ERC721 contain setTokenURI?](https://forum.openzeppelin.com/t/why-doesnt-openzeppelin-erc721-contain-settokenuri/6373/4):
>
> Yes, we think most people should try to avoid setTokenURI if possible for their use case. If you use IFPS, your baseURI wouldn’t be gateway.pinata.cloud, it would be the URI to an IPFS directory. For example, I just uploaded a directory to Pinata at [https://gateway.pinata.cloud/ipfs/QmcP9hxrnC1T5ATPmq2saFeAM1ypFX9BnAswCdHB9JCjLA/](https://gateway.pinata.cloud/ipfs/QmcP9hxrnC1T5ATPmq2saFeAM1ypFX9BnAswCdHB9JCjLA/). I can now create an ERC721 with that URL as its baseURI (or I could use a native ipfs:// protocol URI), and mint token IDs 1 and 2. The concatenated URI for token …

If you still want to have a separate URL for each token, you would need to extend our `ERC1155` implementation and override the `uri(uint256 id)` function to make it return your custom URL. Potentially you can read from a mapping indexed by `id`. Something similar to what [`ERC721URIStorage`](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.3.0/contracts/token/ERC721/extensions/ERC721URIStorage.sol) does.

---

<div class="post-metadata">

**Author:** ![d-sfounis](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/d-sfounis/32/5946_2.png) [@d-sfounis](https://forum.openzeppelin.com/u/d-sfounis)\
**Post date:** [October 16, 2021, 2:44pm UTC](https://forum.openzeppelin.com/t/how-to-have-custom-uri-for-each-token-type-in-erc1155/16752/3 "2021-10-16T14:44:27Z")

</div>

The base URL is basically the "folder". Every URI appended after that is fully separate and there's no need for a centralized host for 'em.

We habitually use IPFS for this and nothing about it is centralized. For example,  
BaseURI being `ipfs://QmAbCD...` and three token URIs being `ipfs://QmAbCD.../foo.tiff`, `ipfs://QmAbCD.../bar.tiff` and `ipfs://QmAbCD.../foobar.tiff`
