需要识别totalSupply。
如果您发现任何潜在的错误或可能导致问题的原因,我将非常感谢您的帮助,防止将来出现任何错误。
为了避免添加参数,因为当验证发生时,我不知道如何将它们放入合同中
我如何在合同中添加名称、符号?我相信这些将是字符串,maxNftSupply为10000,saleStart时间为uints。
如果我能和一个能提供帮助的人进行口头交谈,我会很喜欢这个机会。
合同TestMB是ERC721,可拥有{对uint256使用SafeMath;
string public TEST_PROVENANCE = "";
uint256 public startingIndexBlock;
uint256 public startingIndex;
uint256 public constant testPrice = 80000000000000000; //0.08 ETH
uint public constant maxTestPurchase = 20;
uint256 public MAX_TEST;
bool public saleIsActive = false;
uint256 public REVEAL_TIMESTAMP;
constructor(string memory name, string memory symbol, uint256 maxNftSupply, uint256 saleStart) ERC721(name, symbol) {
MAX_TEST = maxNftSupply;
REVEAL_TIMESTAMP = saleStart + (86400 * 9);
}
function withdraw() public onlyOwner {
(bool os, ) = payable(owner()).call{value: address(this).balance}('');
require(os);
}
function reserveTest() public onlyOwner {
uint supply = totalSupply();
uint i;
for (i = 0; i < 30; i++) {
_safeMint(msg.sender, supply + i);
}
}
function setRevealTimestamp(uint256 revealTimeStamp) public onlyOwner {
REVEAL_TIMESTAMP = revealTimeStamp;
}
/*
* Set provenance once it's calculated
*/
function setProvenanceHash(string memory provenanceHash) public onlyOwner {
TEST_PROVENANCE = provenanceHash;
}
function setBaseURI(string memory _setBaseURI) public onlyOwner {
setBaseURI = _setBaseURI;
}
function flipSaleState() public onlyOwner {
saleIsActive = !saleIsActive;
}
function mintTest(uint numberOfTokens) public payable {
require(saleIsActive, "Sale must be active to mint Test");
require(numberOfTokens <= maxTestPurchase, "Can only mint 20 tokens at a time");
require(totalSupply().add(numberOfTokens) <= MAX_TEST, "Purchase would exceed max supply of Test");
require(testPrice.mul(numberOfTokens) <= msg.value, "Ether value sent is not correct");
for(uint i = 0; i < numberOfTokens; i++) {
uint mintIndex = totalSupply();
if (totalSupply() < MAX_TEST) {
_safeMint(msg.sender, mintIndex);
}
}
if (startingIndexBlock == 0 && (totalSupply() == MAX_TEST || block.timestamp >= REVEAL_TIMESTAMP)) {
startingIndexBlock = block.number;
}
}
function setStartingIndex() public {
require(startingIndex == 0, "Starting index is already set");
require(startingIndexBlock != 0, "Starting index block must be set");
startingIndex = uint(blockhash(startingIndexBlock)) % MAX_TEST;
if (block.number.sub(startingIndexBlock) > 255) {
startingIndex = uint(blockhash(block.number - 1)) % MAX_TEST;
}
if (startingIndex == 0) {
startingIndex = startingIndex.add(1);
}
}
function emergencySetStartingIndexBlock() public onlyOwner {
require(startingIndex == 0, "Starting index is already set");
startingIndexBlock = block.number;
}
}
您的合同继承自ERC721,而不是ERC721Enumerable,后者包含totalSupply((函数,而ERC721没有。你可以做的是将ERC721Enumerable导入到合同中,并让它像这样继承:
contract TestMB is ERC721, ERC721Enumerable, Ownable {}