How to: ERC-1155 ID Substitution for Token URI

great its really help me. thank so much

Actually, since the openzeppelin URI function is virtual, you can override it to change the URI each time you mint tokens. See https://medium.com/coinsbench/fully-decentralized-erc-721-and-erc-1155-nfts-6c229adf9c9b

contract MyNFT_ERC1155 is ERC1155 {
    mapping (uint256 => string) private _tokenURIs;

    constructor() ERC1155("Anything_you_want") {} 

    function uri(uint256 tokenId) override public view 
    returns (string memory) { 
        return(_tokenURIs[tokenId]); 
    } 
    function _setTokenUri(uint256 tokenId, string memory tokenURI)
    private {
         _tokenURIs[tokenId] = tokenURI; 
    } 
}

We have a simple implementation of this idea in in python documented here: https://core.iscc.codes/utilities/utils/#iscc_core.utils.cidv1_hex ...
See functions:

cidv1_hex()
cidv1_to_token_id()
cidv1_from_token_id()

maybe that helps.

I have a similar question around ID substitution.

The standard implies that the {id} MUST be replaced in all attributes within the metadata JSON. In practice I am not seeing this. Does anyone have any experience with this?

I have implemented the example where v1 CID uri implemented

Hey guys, sorry for being late.

I don't know if IPNS would be an option for this?

This is definetly possible.

If you publish your IPNS pointing to the CID of the folder with json files in IPFS, you'll be able to use the most gas efficient method in ERC1155 but with the advantages of the decentralized IPFS scheme.

Just use this format:

https://<your_ipns_id_key>.ipns.domain/{id}.json

Cheers!