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?
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, "");
}
}
Environment
Environment: Truffle, OpenSea