Hello everyone, How i can reserve some tokens for the owner of smart contract.Ex: if the Max supply is 10000 and i want to reserve 100 there's any way to do that. And if i want to have two phases of the mint, first 5000 free mint and rest of 5000 cost 0.05ETH.
Also i changed this function and i'm not sure if that's correct.
modifier mintCompliance(uint256 _mintAmount) {
require(_mintAmount > 0 , 'Invalid mint amount!');
require(totalSupply() + _mintAmount <= maxSupply, 'Max supply exceeded!');
_;
}
This is the smart contract
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.9 <0.9.0;
import 'erc721a/contracts/extensions/ERC721AQueryable.sol';
import '@openzeppelin/contracts/access/Ownable.sol';
import '@openzeppelin/contracts/utils/cryptography/MerkleProof.sol';
import '@openzeppelin/contracts/security/ReentrancyGuard.sol';
contract OREDO is ERC721AQueryable, Ownable, ReentrancyGuard {
using Strings for uint256;
string public uriPrefix = '';
string public uriSuffix = '.json';
uint256 public cost;
uint256 public maxSupply;
bool public paused = true;
bool public revealed = true;
constructor(
string memory _tokenName,
string memory _tokenSymbol,
uint256 _cost,
uint256 _maxSupply
) ERC721A(_tokenName, _tokenSymbol) {
setCost(_cost);
maxSupply = _maxSupply;
}
modifier mintCompliance(uint256 _mintAmount) {
require(_mintAmount > 0 , 'Invalid mint amount!');
require(totalSupply() + _mintAmount <= maxSupply, 'Max supply exceeded!');
_;
}
modifier mintPriceCompliance(uint256 _mintAmount) {
require(msg.value >= cost * _mintAmount, 'Insufficient funds!');
_;
}
function mint(uint256 _mintAmount) public payable mintCompliance(_mintAmount) mintPriceCompliance(_mintAmount) {
require(!paused, 'The contract is paused!');
_safeMint(_msgSender(), _mintAmount);
}
function mintForAddress(uint256 _mintAmount, address _receiver) public mintCompliance(_mintAmount) onlyOwner {
_safeMint(_receiver, _mintAmount);
}
function _startTokenId() internal view virtual override returns (uint256) {
return 1;
}
function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) {
require(_exists(_tokenId), 'ERC721Metadata: URI query for nonexistent token');
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0
? string(abi.encodePacked(currentBaseURI, _tokenId.toString(), uriSuffix))
: '';
}
function setRevealed(bool _state) public onlyOwner {
revealed = _state;
}
function setCost(uint256 _cost) public onlyOwner {
cost = _cost;
}
function setUriPrefix(string memory _uriPrefix) public onlyOwner {
uriPrefix = _uriPrefix;
}
function setUriSuffix(string memory _uriSuffix) public onlyOwner {
uriSuffix = _uriSuffix;
}
function setPaused(bool _state) public onlyOwner {
paused = _state;
}
function withdraw() public onlyOwner nonReentrant {
// =============================================================================
(bool os, ) = payable(owner()).call{value: address(this).balance}('');
require(os);
// =============================================================================
}
function _baseURI() internal view virtual override returns (string memory) {
return uriPrefix;
}
}