Can ERC1155 contract create multiple Collections of Non-Fungible Tokens?

I'm learning ERC1155, and I'm a bit confused.
Currently, I have multiple ERC 721 contracts, one for each collection.
Can I create multiple collections on a single erc1155 contract? Or I will have to create multiple erc1155 contracts, one for each collection?

For example, say I want to create a Football Game with:

  • 4 Collections of NFTs:
    • Players
    • Coaches
    • Jerseys
    • Stadiums

For instance, if I want to create variations of Stadium, can I just mint multiple NFTs with the ID of the Stadium collection?

Or do I have to mint Stadium A with ID 22, Stadium B with ID 23, Stadium C with ID 24, and so on?

:1234: Code to reproduce

//SPDX-License-Identifier: UNLICENSED
pragma solidity 0.7.0;

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/solc-0.7/contracts/token/ERC1155/ERC1155.sol";

contract FootballGame is ERC1155 {
    
    address public admin;
    
    // Non-Fungibles
    uint8 public constant PLAYER = 1;
    uint8 public constant COACH = 2;
    uint8 public constant JERSEY = 3;
    uint8 public constant STADIUM = 4;
    
    
    constructor() ERC1155("https://example.json") {
        admin = msg.sender;
    }
    
    modifier onlyAdmin() {
        require(msg.sender == admin, "This operation is only for Admins");
        _;
    }
    
    
    function mintNFT(uint _tokenId) onlyAdmin external {
        require(_tokenId == PLAYER || _tokenId == COACH || _tokenId == JERSEY || _tokenId == STADIUM, "Invalid Token ID");
        _mint(msg.sender, _tokenId, 1, "");
    }
}

:computer: Environment

Environment: Truffle, OpenSea

ERC1155 is like ERC721 where each id can have supply greater than 1. Within each id the tokens are fungible.

It seems you have categories of items, but within each category the items are non-fungible. So Stadium A si not equivalent with Stadium B.

So ERC1155 doesn't have anything special that would allow you to implement this. You could have a "Stadium" NFT with more than 1 stadium but all of them would be the same stadium.

If you want to do "collections" of different related non fungibles, you can put them all in the same ERC721 contract and use a convention for token ids. For example, all stadium ids can end in "001", all player ids can end in "002", and so on.

1 Like