pragma solidity ^0.8.9; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; contract timeGenesisCard is ERC721URIStorage, Ownable{ using Counters for Counters.Counter; Counters.Counter private _tokenIdCounter; uint256 private immutable totalSupply=10000; //total 10000 uint256 private whiteUserNum; //whitelist amount
//nft uri
string private uri;
constructor() ERC721("Genesis Time Whale", "GTW"){}
address[125] private theseWhiteAddress;
mapping(address=>bool)public userIfWhitelist;
receive() external payable {}
//public mint
function mintTimeWhale()public payable{
//limit total 10000
require(_tokenIdCounter.current()<=totalSupply,"There are no NFTS available for mint anymore");
uint256 tokenId = _tokenIdCounter.current();
uint256 contractFee=price(msg.sender);
userIfWhitelist[msg.sender] = false;
require(msg.value > contractFee,"This address not enough paid");
_safeMint(msg.sender, tokenId);
_setTokenURI(tokenId, uri);
_tokenIdCounter.increment(); //tokenId+1
}
//Add address to whitelist
function addUser(address _user) public onlyOwner{
require(whiteUserNum < 2000, "number of users is limited to 200");
require(userIfWhitelist[_user]==false, "This address has been whitelisted");
theseWhiteAddress[whiteUserNum] = _user;
whiteUserNum++;
userIfWhitelist[_user] = true;
}
//Remove addresses from the whitelist
function removeWhitelist(address _user) public {
require(userIfWhitelist[_user]==true,"not a whitelist");
userIfWhitelist[_user] = false;
}
//fee
function price(address userAddress)public view returns(uint256){
if(userIfWhitelist[userAddress]){
//Whitelist 0.001 fee
return 0.005 ether;
}else{
//Not whitelist 0.01 fee
return 0.02 ether;
}
}
}
require(msg.value > contractFee,"This address not enough paid");使用这句以前是可行的,最近试了下,开发账户还有99eth的,然后我测试msg.value>0,显示报错,也就是得到自身0eth,这是怎么回事呢?