-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathNFT.sol
121 lines (96 loc) · 4 KB
/
NFT.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
contract Doodles is ERC721, ERC721Enumerable, Ownable {
string public PROVENANCE;
bool public saleIsActive = false;
string private _baseURIextended;
bool public isAllowListActive = false;
uint256 public MAX_SUPPLY;
uint256 public MAX_PUBLIC_MINT;
uint256 public PRICE_PER_TOKEN;
string private name;
string private symbol;
mapping(address => uint8) private _allowList;
constructor()
ERC721("name", "symbol") {
}
function setIsAllowListActive(bool _isAllowListActive) external onlyOwner {
isAllowListActive = _isAllowListActive;
}
function setAllowList(address[] calldata addresses, uint8 numAllowedToMint) external onlyOwner {
for (uint256 i = 0; i < addresses.length; i++) {
_allowList[addresses[i]] = numAllowedToMint;
}
}
function numAvailableToMint(address addr) external view returns (uint8) {
return _allowList[addr];
}
function mintAllowList(uint8 numberOfTokens) external payable {
uint256 ts = totalSupply();
require(isAllowListActive, "Allow list is not active");
require(numberOfTokens <= _allowList[msg.sender], "Exceeded max available to purchase");
require(ts + numberOfTokens <= MAX_SUPPLY, "Purchase would exceed max tokens");
require(PRICE_PER_TOKEN * numberOfTokens <= msg.value, "Ether value sent is not correct");
_allowList[msg.sender] -= numberOfTokens;
for (uint256 i = 0; i < numberOfTokens; i++) {
_safeMint(msg.sender, ts + i);
}
}
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal override(ERC721, ERC721Enumerable) {
super._beforeTokenTransfer(from, to, tokenId);
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, ERC721Enumerable) returns (bool) {
return super.supportsInterface(interfaceId);
}
function setBaseURI(string memory baseURI_) external onlyOwner() {
_baseURIextended = baseURI_;
}
function _baseURI() internal view virtual override returns (string memory) {
return _baseURIextended;
}
function setProvenance(string memory provenance) public onlyOwner {
PROVENANCE = provenance;
}
function setCollectionName(string memory name_) external onlyOwner {
name = name_;
}
function setCollectionsymbol(string memory symbol_) external onlyOwner {
symbol = symbol_;
}
function reserve(uint256 n) public onlyOwner {
uint supply = totalSupply();
uint i;
for (i = 0; i < n; i++) {
_safeMint(msg.sender, supply + i);
}
}
function setMaxSupply(uint256 MAX_SUPPLY_) public onlyOwner {
MAX_SUPPLY = MAX_SUPPLY_;
}
function setSaleState(bool newState) public onlyOwner {
saleIsActive = newState;
}
function setSaleState(uint256 MAX_PUBLIC_MINT_) public onlyOwner {
MAX_PUBLIC_MINT = MAX_PUBLIC_MINT_;
}
function setPrice(uint256 PRICE_PER_TOKEN_) public onlyOwner {
PRICE_PER_TOKEN = PRICE_PER_TOKEN_;
}
function mint(uint numberOfTokens) public payable {
uint256 ts = totalSupply();
require(saleIsActive, "Sale must be active to mint tokens");
require(numberOfTokens <= MAX_PUBLIC_MINT, "Exceeded max token purchase");
require(ts + numberOfTokens <= MAX_SUPPLY, "Purchase would exceed max tokens");
require(PRICE_PER_TOKEN * numberOfTokens <= msg.value, "Ether value sent is not correct");
for (uint256 i = 0; i < numberOfTokens; i++) {
_safeMint(msg.sender, ts + i);
}
}
function withdraw() public onlyOwner {
uint balance = address(this).balance;
payable(msg.sender).transfer(balance);
}
}