Skip to content

Commit 5e4f8fe

Browse files
committed
reduced contract cost
1 parent 3451396 commit 5e4f8fe

26 files changed

+46722
-56652
lines changed

README.md

+21-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
# Sport Legends NFT
2+
This project allows to fully build a new NFT collection on Ethereum block-chain and mint them through a ReactJS based website.
3+
4+
There are some key features:
5+
- Image generation is completely random, based on pre-defined percentages, different SVG layers will be combined together. This will result in different clustering groups (common, rare, super-rare).
6+
- The website is built with ReactJS and Web3.
7+
- The generated images will be pushed to IPFS for resiliency and privacy.
8+
- The smart-contract is ERC721 and it leaverage the openzeppelin-solidity library.
9+
- Utility scrits are located under ./scripts folder.
10+
211

312
### Discord Group Invite
413

@@ -61,4 +70,15 @@ N.B. the layers must be visible (up to now we have sublayers as well so this app
6170
for lay in $(inkscape --query-all NFT.svg | grep "g" | grep -v svg | awk -F, '{print $1}'); do
6271
inkscape NFT.svg -i $lay -j -C --export-png=testme/$lay.png;
6372
done
64-
```
73+
```
74+
75+
### Work-arounds
76+
```
77+
export NODE_OPTIONS=--openssl-legacy-provider
78+
```
79+
80+
### COSTS
81+
The cost = Gas Price x Amount of Gas consumed
82+
Cost = 80 Gwei * 2683987M = 214718960M Gwei = 0.21471896eth
83+
Cost = 50 Gwei * 2683987M = 134199350M Gwei = 0.13419935eth
84+

contracts/Migrations.sol

-20
This file was deleted.

contracts/SportSuperstars.sol

+60-92
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
// SPDX-License-Identifier: MIT
32

43
pragma solidity ^0.7.6;
@@ -10,34 +9,73 @@ import "openzeppelin-solidity/contracts/math/SafeMath.sol";
109
contract SportSuperstars is ERC721, Ownable {
1110

1211
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;
1619
bool public saleIsActive = false;
1720
bool public preSaleIsActive = false;
21+
mapping (address => uint256) private _preSaleAddress;
1822

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+
}
2525

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+
}
2937

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+
}
3153

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+
}
3366

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))) : "";
3574
}
3675

3776
function withdraw() public onlyOwner {
3877
uint balance = address(this).balance;
3978
msg.sender.transfer(balance);
40-
emit Transfer(msg.sender, balance);
4179
}
4280

4381
function flipSaleState() public onlyOwner {
@@ -48,97 +86,27 @@ contract SportSuperstars is ERC721, Ownable {
4886
preSaleIsActive = !preSaleIsActive;
4987
}
5088

51-
function setPreSaleMapIndex(uint32 mapIndex) public onlyOwner {
52-
_presaleMapIndex = mapIndex;
53-
}
54-
5589
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;
5892
}
5993
}
6094

6195
function setBaseURI(string memory baseURI) public onlyOwner {
6296
_setBaseURI(baseURI);
6397
}
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-
}
7298

7399
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;
83101
}
84102

85103
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");
87105
uint supply = totalSupply();
88-
uint i;
89-
for (i = 0; i < numberOfTokens; i++) {
106+
for (uint i = 0; i < numberOfTokens; i++) {
90107
_safeMint(msg.sender, supply + i);
91108
}
92109
}
93110

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-
}
103111

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-
}
144112
}
File renamed without changes.

migration/1_initial_migration.js

-5
This file was deleted.

0 commit comments

Comments
 (0)