-
Notifications
You must be signed in to change notification settings - Fork 1
/
S33Ds.sol
81 lines (61 loc) · 2.33 KB
/
S33Ds.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
//SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.0;
import "./Strings.sol";
import "./Ownable.sol";
import "./ERC721.sol";
contract S33Ds is ERC721, Ownable {
address public constant UKRAINE_ETH_ADDRESS = 0x165CD37b4C644C2921454429E7F9358d18A45e14;
uint256 public constant MAX_SUPPLY = 10_000;
uint256 public tokenCost = 0.05 ether;
uint256 public maxMintPerTx = 100;
bool public isSaleActive;
uint256 public totalSupply;
string public baseURI;
constructor() ERC721("S33Ds for Ukraine", "S33Ds") {}
function mint(uint256 _count) external payable {
require(isSaleActive);
require(_count <= maxMintPerTx);
uint256 currentId = totalSupply;
unchecked {
require(currentId + _count <= MAX_SUPPLY);
require(msg.value >= _count * tokenCost);
for (uint256 i; i < _count; ++i) {
// 99% sure this check is not necessary,
// because totalSupply will force mint to always increment to a place where ownerOf == 0x0
// require(ownerOf[id] == address(0), "ALREADY_MINTED");
ownerOf[currentId + i] = msg.sender;
emit Transfer(address(0), msg.sender, currentId + i);
}
balanceOf[msg.sender] += _count;
totalSupply += _count;
}
}
function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) {
require(ownerOf[_tokenId] != address(0));
return string(
abi.encodePacked(
abi.encodePacked(
baseURI,
Strings.toString(_tokenId)
), ".json"
)
);
}
function updateTokenCost(uint256 _tokenCost) external onlyOwner {
tokenCost = _tokenCost;
}
function updateMaxMintPerTx(uint256 _maxMintPerTx) external onlyOwner {
maxMintPerTx = _maxMintPerTx;
}
function updateBaseURI(string memory _baseURI) external onlyOwner {
baseURI = _baseURI;
}
function flipSaleState() external onlyOwner {
isSaleActive = !isSaleActive;
}
function transferFunds() external onlyOwner {
uint256 balance = address(this).balance;
(bool transferTx, ) = payable(UKRAINE_ETH_ADDRESS).call{value: balance}("");
require(transferTx);
}
}