Token URI of ERC1155

Token uri can be fixed. Client(e.g. opensea) will replece {id} with tokenId.

Take this code as example.

 1// SPDX-License-Identifier: MIT
 2pragma solidity ^0.8.4;
 3
 4import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
 5import "@openzeppelin/contracts/access/Ownable.sol";
 6import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Burnable.sol";
 7
 8contract MyToken is ERC1155, Ownable, ERC1155Burnable {
 9    constructor()
10        ERC1155("https://ipfs.io/ipfs/CID/{id}.json")
11    {}
12
13    function setURI(string memory newuri) public onlyOwner {
14        _setURI(newuri);
15    }
16
17    function mint(address account, uint256 id, uint256 amount, bytes memory data)
18        public
19        onlyOwner
20    {
21        _mint(account, id, amount, data);
22    }
23
24    function mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data)
25        public
26        onlyOwner
27    {
28        _mintBatch(to, ids, amounts, data);
29    }
30}

No matter which tokenId you check, you will get the same tokenUri: https://ipfs.io/ipfs/CID/{id}.json. However, Opensea(or any other client) will replace id, so you get the metadata of each token.