Closed mjtpena closed 4 years ago
_mintBatch()
function should be inherited and called by a parent contract, where you would need to add a logic enforcing that each token id can only be minted once.
e.g. something like
contract ERC1155NFT is ERC1155MintBurn {
mapping (uint256 => bool) internal minted;
function batchMintNFT(address _to, uint256[] calldata _ids) external onlyOwners() {
// Number of NFTs to mint
uint256 n_ids = _ids.length;
// Array of 1s for batchmint
uint256[] memory ones = new uint256[](n_ids);
// Enforces that each ID is only minted once
for (uint256 i = 0; i < n_ids; i++) {
require(!minted[_ids[i]], "NFT Already Minted");
minted[_ids[i]] = true;
}
// Mint NFTs
super._batchMint(_to, _ids, ones);
}
}
That's actually very clever. I implemented something similar yesterday
struct TokenSchema {
string tokenType;
string metadataUri;
bool exists;
}
mapping(uint256 => TokenSchema) public tokenIds;
Thank you for the effort of implementing ERC1155.
I was trying to implement the mint and mintBatch functions, but I don't know how to ensure that tokens are unique (NFT). Is it based from the balance of the owners?