简体   繁体   English

如何在 remix 中声明此智能合约中的标识符?

[英]How do I declare the identifier in this smart contract in remix?

Need to identify totalSupply.需要确定totalSupply。

If you find any potential errors or something that can cause an issue, I would highly appreciate you for helping me, preventing any errors in the future.如果您发现任何潜在的错误或可能导致问题的东西,我将非常感谢您帮助我,防止将来出现任何错误。

To avoid adding parameters, because I don't know how to put them into the contract when verification happens避免添加参数,因为我不知道在验证发生时如何将它们放入合约中

How can I add in the name, symbol in the contract I believe those will be strings and the maxNftSupply as 10000 and the saleStart time those would be uints.我如何在合同中添加名称和符号,我相信这些将是字符串,maxNftSupply 为 10000,而 saleStart 时间将是 uint。

If I can have a verbal conversation with someone that can help, I would love that opportunity.如果我可以与可以提供帮助的人进行口头交谈,我会很高兴有这个机会。

contract TestMB is ERC721, Ownable { using SafeMath for uint256;合约 TestMB 是 ERC721,Ownable { using SafeMath for uint256;

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;
}

} }

Your contract inherits from ERC721 instead of ERC721Enumerable , which contains the totalSupply() function, while ERC721 does not.您的合约继承自 ERC721 而不是ERC721Enumerable ,其中包含 totalSupply() function,而 ERC721 没有。 What you can do is import ERC721Enumerable into the contract and have it inherit like so:您可以做的是将 ERC721Enumerable 导入合同并使其继承,如下所示:

contract TestMB is ERC721, ERC721Enumerable, Ownable {}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM