1
-
2
1
// SPDX-License-Identifier: MIT
3
2
4
3
pragma solidity ^ 0.7.6 ;
@@ -10,34 +9,73 @@ import "openzeppelin-solidity/contracts/math/SafeMath.sol";
10
9
contract SportSuperstars is ERC721 , Ownable {
11
10
12
11
using SafeMath for uint256 ;
13
-
14
- event Transfer (address _to , uint _value );
15
-
12
+ uint public constant GIFT_ITEMS = 70 ;
13
+ uint public constant PREADOPT_ITEMS = 700 ;
14
+ uint public constant TOTAL_ITEMS = 7777 ;
15
+ uint public constant MAX_ITEMS_PER_MINT = 10 ;
16
+ uint256 public constant itemPrice = 0.06 ether ;
17
+ uint public giftItems = 0 ;
18
+ uint public preSaleItems = 0 ;
16
19
bool public saleIsActive = false ;
17
20
bool public preSaleIsActive = false ;
21
+ mapping (address => uint256 ) private _preSaleAddress;
18
22
19
- uint256 public constant itemPrice = 0.06 ether ;
20
- uint64 public constant GIFT_ITEMS = 70 ;
21
- uint64 public constant PREADOPT_ITEMS = 700 ;
22
- uint64 public constant ADOPT_ITEMS = 7000 ;
23
- uint128 public constant TOTAL_ITEMS = 7777 ;
24
- uint128 public constant MAX_ITEMS_PER_MINT = 10 ;
23
+ constructor () ERC721 ("Sport Superstars " , "SSS " ) {
24
+ }
25
25
26
- uint256 private giftItems = 0 ;
27
- uint256 private preSaleItems = 0 ;
28
- string private constant IPFS_GUESS_ITEM = "ipfs://QmWuCeHL1uajjNELKfeH18azZ3KSB1YffTtbjaNJqZp19f " ;
26
+ function giftSportSuperstars ( address [] memory recipients ) public onlyOwner {
27
+ require (recipients.length + giftItems < GIFT_ITEMS + 1 , "Max gift " );
28
+ require (totalSupply ().add (recipients.length ) <= TOTAL_ITEMS, "Max supply " );
29
+ uint supply = totalSupply ();
30
+ uint temp = 0 ;
31
+ for ( uint i ; i < recipients.length ; i++ ){
32
+ _safeMint (recipients[i], supply + i );
33
+ temp += 1 ;
34
+ }
35
+ giftItems += temp;
36
+ }
29
37
30
- uint32 private _presaleMapIndex = 1 ;
38
+ function mintPreSaleSportSuperstars (uint tokens ) public payable {
39
+ require (preSaleIsActive, "Pre-sale not active " );
40
+ require (_preSaleAddress[msg .sender ] > 0 , "Not allowed pre-mint " );
41
+ require (tokens + preSaleItems < PREADOPT_ITEMS + 1 , "Pre-sale exceed " );
42
+ require (tokens <= MAX_ITEMS_PER_MINT, "Max 10 items " );
43
+ require (totalSupply ().add (tokens) <= TOTAL_ITEMS, "Purchase exceed " );
44
+ require (msg .value == itemPrice.mul (tokens), "Ether not correct " );
45
+ for (uint i = 0 ; i < tokens; i++ ) {
46
+ uint mintIndex = totalSupply ();
47
+ if (mintIndex < TOTAL_ITEMS && preSaleItems < PREADOPT_ITEMS + 1 ) {
48
+ _safeMint (msg .sender , mintIndex);
49
+ preSaleItems += 1 ;
50
+ }
51
+ }
52
+ }
31
53
32
- mapping (uint32 => mapping (address => uint32 )) private _preSaleAddress;
54
+ function mintSportSuperstars (uint tokens ) public payable {
55
+ require (saleIsActive, "Sale not active " );
56
+ require (tokens <= MAX_ITEMS_PER_MINT, "Max 10 items " );
57
+ require (totalSupply ().add (tokens) <= TOTAL_ITEMS, "Purchase exceed " );
58
+ require (msg .value == itemPrice.mul (tokens), "Ether not correct " );
59
+ for (uint i = 0 ; i < tokens; i++ ) {
60
+ uint mintIndex = totalSupply ();
61
+ if (mintIndex < TOTAL_ITEMS) {
62
+ _safeMint (msg .sender , mintIndex);
63
+ }
64
+ }
65
+ }
33
66
34
- constructor () ERC721 ("Sport Superstars " , "SSS " ) {
67
+ function tokenURI (uint256 tokenId ) public view virtual override returns (string memory ) {
68
+ require (_exists (tokenId), "Token doesn't exist " );
69
+ string memory baseURI = baseURI ();
70
+ if ( bytes (baseURI).length == 0 ){
71
+ return "ipfs://QmWuCeHL1uajjNELKfeH18azZ3KSB1YffTtbjaNJqZp19f " ;
72
+ }
73
+ return bytes (baseURI).length > 0 ? string (abi.encodePacked (baseURI, Strings.toString (tokenId))) : "" ;
35
74
}
36
75
37
76
function withdraw () public onlyOwner {
38
77
uint balance = address (this ).balance;
39
78
msg .sender .transfer (balance);
40
- emit Transfer (msg .sender , balance);
41
79
}
42
80
43
81
function flipSaleState () public onlyOwner {
@@ -48,97 +86,27 @@ contract SportSuperstars is ERC721, Ownable {
48
86
preSaleIsActive = ! preSaleIsActive;
49
87
}
50
88
51
- function setPreSaleMapIndex (uint32 mapIndex ) public onlyOwner {
52
- _presaleMapIndex = mapIndex;
53
- }
54
-
55
89
function setPreSalesAddresses ( address [] memory recipients ) public onlyOwner {
56
- for ( uint256 i ; i < recipients.length ; i++ ){
57
- _preSaleAddress[_presaleMapIndex][ recipients[i]] = 1 ;
90
+ for ( uint i ; i < recipients.length ; i++ ){
91
+ _preSaleAddress[recipients[i]] = 1 ;
58
92
}
59
93
}
60
94
61
95
function setBaseURI (string memory baseURI ) public onlyOwner {
62
96
_setBaseURI (baseURI);
63
97
}
64
-
65
- function setTokenURI (uint256 tokenId , string memory _tokenURI ) public onlyOwner {
66
- _setTokenURI (tokenId, _tokenURI);
67
- }
68
-
69
- function getPreSaleMapIndex () public view returns ( uint32 ) {
70
- return _presaleMapIndex;
71
- }
72
98
73
99
function isAddressAllowedForPreSale (address recipient ) public view returns ( bool ) {
74
- return _preSaleAddress[_presaleMapIndex][recipient] > 0 ;
75
- }
76
-
77
- function getGiftItems () public view returns ( uint256 ){
78
- return giftItems;
79
- }
80
-
81
- function getPreSaleItems () public view returns ( uint256 ){
82
- return preSaleItems;
100
+ return _preSaleAddress[recipient] > 0 ;
83
101
}
84
102
85
103
function reserveItems (uint numberOfTokens ) public onlyOwner {
86
- require (totalSupply ().add (numberOfTokens) <= TOTAL_ITEMS, "Reserved items would exceed max supply " );
104
+ require (totalSupply ().add (numberOfTokens) <= TOTAL_ITEMS, "Exceed max supply " );
87
105
uint supply = totalSupply ();
88
- uint i;
89
- for (i = 0 ; i < numberOfTokens; i++ ) {
106
+ for (uint i = 0 ; i < numberOfTokens; i++ ) {
90
107
_safeMint (msg .sender , supply + i);
91
108
}
92
109
}
93
110
94
- function giftSportSuperstars ( address [] memory recipients ) public onlyOwner {
95
- require (recipients.length + giftItems < GIFT_ITEMS + 1 , "Can't gift more than 70 items " );
96
- require (totalSupply ().add (recipients.length ) <= TOTAL_ITEMS, "Gift items would exceed max supply " );
97
- uint256 supply = totalSupply ();
98
- for ( uint256 i ; i < recipients.length ; i++ ){
99
- _safeMint (recipients[i], supply + i );
100
- giftItems += 1 ;
101
- }
102
- }
103
111
104
- function mintPreSaleSportSuperstars (uint numberOfTokens ) public payable {
105
- require (preSaleIsActive, "Pre sale must be active to mint " );
106
- require (_preSaleAddress[_presaleMapIndex][msg .sender ] > 0 , "You are not allowed to partecipate to the pre sale mint " );
107
- require (numberOfTokens + preSaleItems < PREADOPT_ITEMS + 1 , "Can't mint more than 700 items " );
108
- require (numberOfTokens <= MAX_ITEMS_PER_MINT, "Can't mint more than 10 items " );
109
- require (totalSupply ().add (numberOfTokens) <= TOTAL_ITEMS, "Purchase would exceed max supply " );
110
- require (msg .value == itemPrice.mul (numberOfTokens), "Ether value sent is not correct " );
111
-
112
- for (uint i = 0 ; i < numberOfTokens; i++ ) {
113
- uint mintIndex = totalSupply ();
114
- if (totalSupply () < TOTAL_ITEMS && preSaleItems < PREADOPT_ITEMS + 1 ) {
115
- _safeMint (msg .sender , mintIndex);
116
- preSaleItems += 1 ;
117
- }
118
- }
119
- }
120
-
121
- function mintSportSuperstars (uint numberOfTokens ) public payable {
122
- require (saleIsActive, "Sale must be active to mint " );
123
- require (numberOfTokens <= MAX_ITEMS_PER_MINT, "Can't mint more than 10 items " );
124
- require (totalSupply ().add (numberOfTokens) <= TOTAL_ITEMS, "Purchase would exceed max supply " );
125
- require (msg .value == itemPrice.mul (numberOfTokens), "Ether value sent is not correct " );
126
-
127
- for (uint i = 0 ; i < numberOfTokens; i++ ) {
128
- uint mintIndex = totalSupply ();
129
- if (totalSupply () < TOTAL_ITEMS) {
130
- _safeMint (msg .sender , mintIndex);
131
- }
132
- }
133
- }
134
-
135
- function tokenURI (uint256 tokenId ) public view virtual override returns (string memory ) {
136
- require (_exists (tokenId), "ERC721Metadata: URI query for nonexistent token " );
137
-
138
- string memory baseURI = baseURI ();
139
- if ( bytes (baseURI).length == 0 ){
140
- return IPFS_GUESS_ITEM;
141
- }
142
- return bytes (baseURI).length > 0 ? string (abi.encodePacked (baseURI, Strings.toString (tokenId))) : "" ;
143
- }
144
112
}
0 commit comments