-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNFTStackSmartContract.sol
More file actions
237 lines (185 loc) · 7.16 KB
/
Copy pathNFTStackSmartContract.sol
File metadata and controls
237 lines (185 loc) · 7.16 KB
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
//
// Made by: NFT Stack
// https://nftstack.info
//
pragma solidity ^0.8.1;
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract NFTStackSmartContract is ERC721Enumerable, Ownable {
uint256 public mintPrice = 0.001 ether;
uint256 public preSaleMintPrice = 0.001 ether;
uint256 private reserveAtATime = 50;
uint256 private reservedCount = 0;
uint256 private maxReserveCount = 200;
string _baseTokenURI;
bool public isMintActive = false;
bool public isPreSaleMintActive = false;
bool public isClosedMintForever = false;
uint256 public maximumMintSupply = 10000;
uint256 public maximumAllowedTokensPerPurchase = 10;
uint256 public maximumAllowedTokensPerWallet = 10;
uint256 public allowListMaxMint = 10;
address private OtherAddress = 0x9DbF14C79847D1566419dCddd5ad35DAf0382E05;
mapping(address => bool) private _allowList;
mapping(address => uint256) private _allowListClaimed;
event AssetMinted(uint256 tokenId, address sender);
event SaleActivation(bool isMintActive);
constructor(string memory baseURI) ERC721("NFTStack Smart Contract", "NFTSSC") {
setBaseURI(baseURI);
}
modifier saleIsOpen {
require(totalSupply() <= maximumMintSupply, "Sale has ended.");
_;
}
modifier onlyAuthorized() {
require(owner() == msg.sender);
_;
}
function setMaximumAllowedTokens(uint256 _count) public onlyAuthorized {
maximumAllowedTokensPerPurchase = _count;
}
function setMaximumAllowedTokensPerWallet(uint256 _count) public onlyAuthorized {
maximumAllowedTokensPerWallet = _count;
}
function setMintActive(bool val) public onlyAuthorized {
isMintActive = val;
emit SaleActivation(val);
}
function setMaxMintSupply(uint256 maxMintSupply) external onlyAuthorized {
maximumMintSupply = maxMintSupply;
}
function setIsPreSaleMintActive(bool _isPreSaleMintActive) external onlyAuthorized {
isPreSaleMintActive = _isPreSaleMintActive;
}
function setAllowListMaxMint(uint256 maxMint) external onlyAuthorized {
allowListMaxMint = maxMint;
}
function addToAllowList(address[] calldata addresses) external onlyAuthorized {
for (uint256 i = 0; i < addresses.length; i++) {
require(addresses[i] != address(0), "Can't add a null address");
_allowList[addresses[i]] = true;
_allowListClaimed[addresses[i]] > 0 ? _allowListClaimed[addresses[i]] : 0;
}
}
function checkIfOnAllowList(address addr) external view returns (bool) {
return _allowList[addr];
}
function removeFromAllowList(address[] calldata addresses) external onlyAuthorized {
for (uint256 i = 0; i < addresses.length; i++) {
require(addresses[i] != address(0), "Can't add a null address");
_allowList[addresses[i]] = false;
}
}
function allowListClaimedBy(address owner) external view returns (uint256){
require(owner != address(0), 'Zero address not on Allow List');
return _allowListClaimed[owner];
}
function setReserveAtATime(uint256 val) public onlyAuthorized {
reserveAtATime = val;
}
function setMaxReserve(uint256 val) public onlyAuthorized {
maxReserveCount = val;
}
function setMintPrice(uint256 _price) public onlyAuthorized {
mintPrice = _price;
}
function setPreSaleMintPrice(uint256 _price) public onlyAuthorized {
preSaleMintPrice = _price;
}
function setBaseURI(string memory baseURI) public onlyAuthorized {
_baseTokenURI = baseURI;
}
function getMaximumAllowedTokens() public view onlyAuthorized returns (uint256) {
return maximumAllowedTokensPerPurchase;
}
function getMintPrice() external view returns (uint256) {
return mintPrice;
}
function getPreSaleMintPrice() external view returns (uint256) {
return preSaleMintPrice;
}
function getIsClosedMintForever() external view returns (bool) {
return isClosedMintForever;
}
function setIsClosedMintForever() external onlyAuthorized {
isClosedMintForever = true;
}
function getReserveAtATime() external view returns (uint256) {
return reserveAtATime;
}
function getTotalSupply() external view returns (uint256) {
return totalSupply();
}
function getContractOwner() public view returns (address) {
return owner();
}
function _baseURI() internal view virtual override returns (string memory) {
return _baseTokenURI;
}
function reserveNft() public onlyAuthorized {
require(reservedCount <= maxReserveCount, "Max Reserves taken already!");
uint256 supply = totalSupply();
uint256 i;
for (i = 0; i < reserveAtATime; i++) {
emit AssetMinted(supply + i, msg.sender);
_safeMint(msg.sender, supply + i);
reservedCount++;
}
}
function reserveToCustomWallet(address _walletAddress, uint256 _count) public onlyAuthorized {
require(reservedCount <= maxReserveCount, "Max Reserves taken already!");
uint256 supply = totalSupply();
uint256 i;
for (i = 0; i < _count; i++) {
emit AssetMinted(supply + i, _walletAddress);
_safeMint(_walletAddress, totalSupply());
}
}
function mint(address _to, uint256 _count) public payable saleIsOpen {
if (msg.sender != owner()) {
require(isMintActive, "Sale is not active currently.");
}
if(_to != owner()) {
require(balanceOf(_to) + _count <= maximumAllowedTokensPerWallet, "Max holding cap reached.");
}
require(totalSupply() + _count <= maximumMintSupply, "Total supply exceeded.");
require(totalSupply() <= maximumMintSupply, "Total supply spent.");
require(
_count <= maximumAllowedTokensPerPurchase,
"Exceeds maximum allowed tokens"
);
require(!isClosedMintForever, "Mint Closed Forever");
require(msg.value >= mintPrice * _count, "Insuffient ETH amount sent.");
for (uint256 i = 0; i < _count; i++) {
emit AssetMinted(totalSupply(), _to);
_mint(_to, totalSupply());
}
}
function preSaleMint(uint256 _count) public payable saleIsOpen {
require(isPreSaleMintActive, 'Pre Sale Mint is not active');
require(_allowList[msg.sender], 'You are not on the Allow List');
require(totalSupply() < maximumMintSupply, 'All tokens have been minted');
require(_count <= allowListMaxMint, 'Cannot purchase this many tokens');
require(_allowListClaimed[msg.sender] + _count <= allowListMaxMint, 'Purchase exceeds max allowed');
require(msg.value >= preSaleMintPrice * _count, 'Insuffient ETH amount sent.');
require(!isClosedMintForever, 'Mint Closed Forever');
for (uint256 i = 0; i < _count; i++) {
_allowListClaimed[msg.sender] += 1;
emit AssetMinted(totalSupply(), msg.sender);
_mint(msg.sender, totalSupply());
}
}
function walletOfOwner(address _owner) external view returns(uint256[] memory) {
uint tokenCount = balanceOf(_owner);
uint256[] memory tokensId = new uint256[](tokenCount);
for(uint i = 0; i < tokenCount; i++){
tokensId[i] = tokenOfOwnerByIndex(_owner, i);
}
return tokensId;
}
function withdraw() external onlyAuthorized {
uint balance = address(this).balance;
payable(OtherAddress).transfer(balance * 10000 / 10000);
payable(owner()).transfer(balance * 0 / 10000);
}
}