forked from NazaWEb/ultimate-smart-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Web3BuildersERC721.sol
99 lines (81 loc) · 2.98 KB
/
Web3BuildersERC721.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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
contract Web3Builders is ERC721, ERC721Enumerable, Pausable, Ownable {
using Counters for Counters.Counter;
uint256 maxSupply = 2000;
bool public publicMintOpen = false;
bool public allowListMintOpen = false;
mapping(address => bool) public allowList;
Counters.Counter private _tokenIdCounter;
constructor() ERC721("Web3Builders", "WE3") {}
function _baseURI() internal pure override returns (string memory) {
return "ipfs://Qmaa6TuP2s9pSKczHF4rwWhTKUdygrrDs8RmYYqCjP3Hye/";
}
function pause() public onlyOwner {
_pause();
}
function unpause() public onlyOwner {
_unpause();
}
// Modify the mint windows
function editMintWindows(
bool _publicMintOpen,
bool _allowListMintOpen
) external onlyOwner {
publicMintOpen = _publicMintOpen;
allowListMintOpen = _allowListMintOpen;
}
// require only the allowList people to mint
// Add publicMint and allowListMintOpen Variables
function allowListMint() public payable {
require(allowListMintOpen, "Allowlist Mint Closed");
require(allowList[msg.sender], "You are not on the allow list");
require(msg.value == 0.001 ether, "Not Enough Funds");
internalMint();
}
// Add Payment
// Add limiting of supply
function publicMint() public payable {
require(publicMintOpen, "Public Mint Closed");
require(msg.value == 0.01 ether, "Not Enough Funds");
internalMint();
}
function internalMint() internal {
require(totalSupply() < maxSupply, "We Sold Out!");
uint256 tokenId = _tokenIdCounter.current();
_tokenIdCounter.increment();
_safeMint(msg.sender, tokenId);
}
function withdraw(address _addr) external onlyOwner {
// get the balance of the contract
uint256 balalnce = address(this).balance;
payable(_addr).transfer(balalnce);
}
// Populate the Allow List
function setAllowList(address[] calldata addresses) external onlyOwner {
for(uint256 i = 0; i < addresses.length; i++){
allowList[addresses[i]] = true;
}
}
function _beforeTokenTransfer(address from, address to, uint256 tokenId)
internal
whenNotPaused
override(ERC721, ERC721Enumerable)
{
super._beforeTokenTransfer(from, to, tokenId);
}
// The following functions are overrides required by Solidity.
function supportsInterface(bytes4 interfaceId)
public
view
override(ERC721, ERC721Enumerable)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
}