becrypto/contracts/tokens/erc721/BEPresaleBox.sol
2022-11-22 17:35:40 +08:00

50 lines
1.2 KiB
Solidity

// SPDX-License-Identifier: MIT
pragma solidity 0.8.10;
import "./BEBase.sol";
contract BEPresaleBox is BEBase {
/**
* type of NFT the box has
* 0: not specify
* 1: hero
* 2: weanpon
* 3: chip
* 301: chip lvl1, 302: lvl2
*/
mapping(uint256 => uint256) public _nftType;
constructor() ERC721("CRYPTO ELITE'S Presale BOXES", "PBOX") {}
function mintBox(address to, uint256 tokenId, uint256 nftType)
external
virtual
onlyRole(MINTER_ROLE)
{
require(!_exists(tokenId), "Must have unique tokenId");
// We cannot just use balanceOf to create the new tokenId because tokens
// can be burned (destroyed), so we need a separate counter.
_nftType[tokenId] = nftType;
_mint(to, tokenId);
}
function burn(address owner, uint256 tokenId)
external
virtual
override
onlyRole(BURN_ROLE)
{
require(_exists(tokenId), "TokenId not exists");
require(!lockedTokens[tokenId], "Can not burn locked token");
require(
ownerOf(tokenId) == owner,
"current address is not owner of this item now"
);
delete _nftType[tokenId];
_burn(tokenId);
}
function getNftType(uint256 tokenId) external view returns (uint256) {
return _nftType[tokenId];
}
}