Skip to content

Commit d114639

Browse files
authored
Update ContractNFTLowGasERC721A.sol
1 parent 8ba5e79 commit d114639

File tree

1 file changed

+27
-45
lines changed

1 file changed

+27
-45
lines changed

ContractNFTLowGasERC721A.sol

Lines changed: 27 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,28 @@ import 'erc721a/contracts/ERC721A.sol';
99

1010
pragma solidity >=0.8.13 <0.9.0;
1111

12-
contract SampleNFTLowGas is ERC721A, Ownable, ReentrancyGuard { //Change contract name from SampleNFTLowGas
12+
contract NFTcontractName is ERC721A, Ownable, ReentrancyGuard { //Change contract name from SampleNFTLowGas
1313

1414
using Strings for uint256;
1515

1616
// ================== Variables Start =======================
17-
17+
1818
string public uri; //you don't change this
19-
string public hiddenMetadataUri; //you don't change this
2019
string public uriSuffix = ".json"; //you don't change this
21-
uint256 public cost1 = 0 ether; //here you change phase 1 cost (for example first 1k for free, then 0.003eth each nft)
22-
uint256 public cost2 = 0.003 ether; //here you change phase 2 cost
23-
uint256 public supplyPhase1 = 1000; //change to your NFT supply for phase1
24-
uint256 public supplyLimit = 3333; //change it to your total NFT supply
25-
uint256 public maxMintAmountPerTxPhase1 = 2; //decide how many NFT's you want to mint with cost1
26-
uint256 public maxMintAmountPerTxPhase2 = 8; //decide how many NFT's you want to mint with cost2
27-
uint256 public maxLimitPerWallet = 10; //decide how many NFT's you want to let customers mint per wallet
28-
bool public sale = true; //if false, then mint is paused. If true - mint is started
20+
string public hiddenMetadataUri; //you don't change this
21+
uint256 public cost1 = 0 ether; //here you change phase 1 cost (for example first 1k for free, then 0.004 eth each nft)
22+
uint256 public cost2 = 0.004 ether; //here you change phase 2 cost
23+
uint256 public supplyLimitPhase1 = 1111; //change to your NFT supply for phase1
24+
uint256 public supplyLimit = 3333; //change it to your total NFT supply
25+
uint256 public maxMintAmountPerTxPhase1 = 1; //decide how many NFT's you want to mint with cost1
26+
uint256 public maxMintAmountPerTxPhase2 = 5; //decide how many NFT's you want to mint with cost2
27+
uint256 public maxLimitPerWallet = 20; //decide how many NFT's you want to let customers mint per wallet
28+
bool public sale = false; //if false, then mint is paused. If true - mint is started
2929
bool public revealed = true; //when you want instant reveal, leave true.
3030

31-
// ================== Variables End =======================
31+
// ================== Variables End =======================
3232

3333
// ================== Constructor Start =======================
34-
3534
constructor(
3635
string memory _uri,
3736
string memory _hiddenMetadataUri
@@ -40,36 +39,26 @@ contract SampleNFTLowGas is ERC721A, Ownable, ReentrancyGuard { //Change contrac
4039
setHiddenMetadataUri(_hiddenMetadataUri);
4140
}
4241

43-
// ================== Constructor End =======================
44-
4542
// ================== Mint Functions Start =======================
4643

47-
function UpdateCost(uint256 _mintAmount) internal view returns (uint256 _cost) {
44+
function UpdateCost(uint256 _mintAmount) internal view returns (uint256 _cost) {
4845

49-
if (balanceOf(msg.sender) + _mintAmount <= maxMintAmountPerTxPhase1 && totalSupply() < supplyPhase1) {
50-
return cost1;
51-
}
52-
if (balanceOf(msg.sender) + _mintAmount > maxMintAmountPerTxPhase1){
53-
return cost2;
54-
}
46+
if (balanceOf(msg.sender) + _mintAmount <= maxMintAmountPerTxPhase1 && totalSupply() < supplyLimitPhase1) {
47+
return cost1;
48+
}
49+
if (balanceOf(msg.sender) + _mintAmount <= maxMintAmountPerTxPhase2){
50+
return cost2;
51+
}
5552
}
5653

5754
function Mint(uint256 _mintAmount) public payable {
58-
59-
//Normal requirements
55+
// Normal requirements
6056
require(sale, 'The Sale is paused!');
61-
require(_mintAmount > 0 && _mintAmount <= maxLimitPerWallet, 'Invalid mint amount!');
57+
require(_mintAmount > 0 && _mintAmount <= maxMintAmountPerTxPhase2, 'Invalid mint amount!');
6258
require(totalSupply() + _mintAmount <= supplyLimit, 'Max supply exceeded!');
6359
require(balanceOf(msg.sender) + _mintAmount <= maxLimitPerWallet, 'Max mint per wallet exceeded!');
64-
if(balanceOf(msg.sender) == 0){
65-
require(msg.value >= UpdateCost(_mintAmount) * (_mintAmount-maxMintAmountPerTxPhase1), 'Insufficient funds!');
66-
}else{
6760
require(msg.value >= UpdateCost(_mintAmount) * _mintAmount, 'Insufficient funds!');
68-
}
69-
require((balanceOf(msg.sender) + _mintAmount <= maxMintAmountPerTxPhase1 && totalSupply() < supplyPhase1) ||
70-
(balanceOf(msg.sender) + _mintAmount <= maxMintAmountPerTxPhase2 && totalSupply() <= supplyPhase1), 'Max mint amount exceeded!');
71-
72-
//Mint
61+
7362
_safeMint(_msgSender(), _mintAmount);
7463
}
7564

@@ -78,10 +67,6 @@ contract SampleNFTLowGas is ERC721A, Ownable, ReentrancyGuard { //Change contrac
7867
_safeMint(_receiver, _mintAmount);
7968
}
8069

81-
// ================== Mint Functions End =======================
82-
83-
// ================== Set Functions Start =======================
84-
8570
function setRevealed(bool _state) public onlyOwner {
8671
revealed = _state;
8772
}
@@ -91,7 +76,7 @@ contract SampleNFTLowGas is ERC721A, Ownable, ReentrancyGuard { //Change contrac
9176
}
9277

9378
function setHiddenMetadataUri(string memory _hiddenMetadataUri) public onlyOwner {
94-
hiddenMetadataUri = _hiddenMetadataUri;
79+
hiddenMetadataUri = _hiddenMetadataUri;
9580
}
9681

9782
function setUriSuffix(string memory _uriSuffix) public onlyOwner {
@@ -132,15 +117,15 @@ contract SampleNFTLowGas is ERC721A, Ownable, ReentrancyGuard { //Change contrac
132117
(bool os, ) = payable(owner()).call{value: address(this).balance}("");
133118
require(os);
134119
}
135-
120+
136121
function price(uint256 _mintAmount) public view returns (uint256){
137-
if (balanceOf(msg.sender) + _mintAmount <= maxMintAmountPerTxPhase1 && totalSupply() < supplyPhase1) {
122+
if (balanceOf(msg.sender) + _mintAmount <= maxMintAmountPerTxPhase1 && totalSupply() <supplyLimitPhase1) {
138123
return cost1;
139124
}
140-
if (balanceOf(msg.sender) + _mintAmount <= maxLimitPerWallet && totalSupply() >= supplyPhase1){
125+
if (balanceOf(msg.sender) + _mintAmount <= maxMintAmountPerTxPhase2 && totalSupply() < supplyLimit){
141126
return cost2;
142127
}
143-
return cost2;
128+
return cost2;
144129
}
145130

146131
function tokensOfOwner(address owner) external view returns (uint256[] memory) {
@@ -185,7 +170,4 @@ function tokensOfOwner(address owner) external view returns (uint256[] memory) {
185170
function _baseURI() internal view virtual override returns (string memory) {
186171
return uri;
187172
}
188-
189-
// ================== Read Functions End =======================
190-
191173
}

0 commit comments

Comments
 (0)