-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLotteryNFTTicket.sol
62 lines (52 loc) · 1.7 KB
/
LotteryNFTTicket.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol";
contract NFTLOTTERY is ERC721, Pausable, AccessControl, ERC721Burnable {
bytes32 public constant CEO = keccak256("CEO");
bytes32 public constant CTO = keccak256("CTO");
bytes32 public constant CFO = keccak256("CFO");
modifier validate() {
require(
hasRole(CEO, msg.sender) ||
hasRole(CFO, msg.sender) ||
hasRole(CTO, msg.sender),
"AccessControl: Address does not have valid Rights"
);
_;
}
constructor() ERC721("NFT LOTTERY", "LOTTO") {
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
_grantRole(CEO, msg.sender);
}
function pause() public validate{
_pause();
}
function unpause() public validate {
_unpause();
}
function safeMint(address to, uint256 tokenId) public validate {
if (_exists(tokenId)){
_burn(tokenId);
}
_safeMint(to, tokenId);
}
function _beforeTokenTransfer(address from, address to, uint256 tokenId)
internal
whenNotPaused
override
{
super._beforeTokenTransfer(from, to, tokenId);
}
// The following functions are overrides required by Solidity.
function supportsInterface(bytes4 interfaceId)
public
view
override(ERC721, AccessControl)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
}