Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update error handling from NFTPort #88

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 126 additions & 0 deletions contracts/contract
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.10;

import "@openzeppelin/contracts/access/Ownable.sol";
import "erc721a/contracts/ERC721A.sol";
import "@openzeppelin/contracts/utils/Strings.sol";

import "@openzeppelin/contracts/security/ReentrancyGuard.sol";


contract VampirestownNFT is ERC721A, Ownable, ReentrancyGuard {

using Strings for uint256;


uint256 price;
uint256 _maxSupply;
uint256 maxMintAmountPerTx; // change when free mint will run out
uint256 maxMintAmountPerWallet; //change when free mint will run out

string baseURL = "QmWAoaxG6xba8dGqLLu2FmHL1BQeHsUAkAZJH7pYfBhj6w";
string ExtensionURL = ".json";




bool paused = false;


constructor(uint256 __maxSupply, string memory _initBaseURI, uint256 _maxMintAmountPerTx, uint256 _maxMintAmountPerWallet) ERC721A("vampirestown", "VAMPIRE") {

baseURL = _initBaseURI;
price = 0.005 ether;
_maxSupply = __maxSupply;
maxMintAmountPerTx = _maxMintAmountPerTx;
maxMintAmountPerWallet = _maxMintAmountPerWallet;


}
function priceUpdate(uint256 _supply) internal pure returns (uint256 _price){
if(_supply < 25) {
return 0 ether;
}
else {
return 0.005 ether;
}
}
// ================== Mint Function =======================

function mint(address to, uint256 _mintAmount) public payable{
uint256 supply = totalSupply();
require(!paused, "The contract is paused!");
require(_mintAmount > 0 && _mintAmount <= maxMintAmountPerTx, "Invalid mint amount!");
require(supply + _mintAmount <= _maxSupply, "You want to suck too much blood. Max supply exceeded!");
require(msg.value >= priceUpdate(supply) * _mintAmount, "Are your fangs too short, or you dont have enough funds?");
require(balanceOf(msg.sender) + _mintAmount <= maxMintAmountPerWallet, "Dont be greedy! Max mint per wallet exceeded!");





_safeMint(to, _mintAmount);
}
// ================== Orange Functions (Owner Only) ===============

function pause(bool state) public onlyOwner {
paused = state;
}

function safeMint(address to, uint256 quantity) public onlyOwner {
_safeMint(to, quantity);
}

function setbaseURL(string memory uri) public onlyOwner{
baseURL = uri;
}

function setExtensionURL(string memory uri) public onlyOwner{
ExtensionURL = uri;
}

function setCostPrice(uint256 _cost) public onlyOwner{
price = _cost;
}

function setSupply(uint256 supply) public onlyOwner{
_maxSupply = supply;
}

// ================================ Withdraw Function ====================

function withdraw() public onlyOwner nonReentrant{

uint256 CurrentContractBalance = address(this).balance;
(bool os, ) = payable(owner()).call{value: CurrentContractBalance}("");
require(os);

}

// =================== Blue Functions (View Only) ====================

function tokenURI(uint256 tokenId) public view override(ERC721A) 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(), ExtensionURL))
: '';

}

function cost() public view returns (uint256){
return price;
}

function _baseURI() internal view virtual override returns (string memory) {
return baseURL;
}

function maxSupply() public view returns (uint256){
return _maxSupply;

}
}
Loading