ERC1155 totalSupply

:computer: Environment
OpenZeppelin v4

:memo:Details
Is there any plan to implement “Split ID bits” and balanceOf a Token id ? as mentionned in eip-1155

Currently it seems, as _balances beeing private in ERC1155.sol, there are no way to make an extension to supercharge safely _mint and _burn functions

Hello @zapaz

That is true, it is not possible to interact with the _balances storage directly. You can hovewer call _mint and _burn, either in other function, or in overload that (using super). Here is an example of an extension that does just that

Now about Split ID bits. AKAIK, these are just convention about how the tokenId is defined. Can you tell us more about what you are trying to achieve ?

2 Likes

Here is an example of an extension that does just that

it’s almost exactly what I was looking for , thanks !
also want an overall totalSupply, but will be easy to derive from your code

the idea behind ‘Split ID bits’ would be to have :

  • balanceOf( baseTokenNFT_id, address) = totalSupply of this NFT collection for address
  • balanceOf( id, 0x ) = totalSupply of FT, NFT or NFT collection