简体   繁体   English

需要审查我的 Solidity 合同,原始代码有 arguments,但我不知道如何输入,也不知道它们的意思

[英]Need My Solidity Contract Reviewed, the original code had arguments, but I don't know how to input that in nor what they mean

How do I add in the arguments and set the baseURI?如何添加 arguments 并设置 baseURI? It is mainly having issues identifying totalsupply and baseuri.它主要在识别总供应量和 baseuri 方面存在问题。 input the below name (string): Test MB symbol (string): TEST maxNftSupply (uint256): 10000 saleStart (uint256): 1619060439?输入以下名称(字符串): 测试 MB 符号(字符串): TEST maxNftSupply (uint256): 10000 saleStart (uint256): 1619060439? Where would I put this, there is also an encoded view after verification on etherscan, is that something I need to add?我会把这个放在哪里,在 etherscan 上验证后还有一个编码视图,这是我需要添加的东西吗?

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 + (9900 * 9);
}

function withdraw() public onlyOwner {
    uint balance = address(this).balance;
    msg.sender.transfer(balance);
}


function reserveTest() public onlyOwner {        
    uint supply = totalSupply();
    uint i;
    for (i = 0; i < 100; i++) {
        _safeMint(msg.sender, supply + i);
    }
}


function setRevealTimestamp(uint256 revealTimeStamp) public onlyOwner {
    REVEAL_TIMESTAMP = revealTimeStamp;
} 

function setProvenanceHash(string memory provenanceHash) public onlyOwner {
    TEST_PROVENANCE = provenanceHash;
}

function setBaseURI(string memory baseURI) public onlyOwner {
    _setBaseURI(baseURI);
}


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;
    // Just a sanity case in the worst case if this function is called late (EVM only stores last 256 block hashes)
    if (block.number.sub(startingIndexBlock) > 255) {
        startingIndex = uint(blockhash(block.number - 1)) % MAX_TEST;
    }
    // Prevent default sequence
    if (startingIndex == 0) {
        startingIndex = startingIndex.add(1);
    }
}


function emergencySetStartingIndexBlock() public onlyOwner {
    require(startingIndex == 0, "Starting index is already set");
    
    startingIndexBlock = block.number;
}

} }

If you are the deployer of the contract so you will be the contract owner.如果您是合约的部署者,那么您将成为合约的所有者。 Then you will be able to call onlyOwner functions.然后您将能够调用 onlyOwner 函数。

To set baseURI, you have to call setBaseURI function with parameter of your base url.要设置 baseURI,您必须调用 setBaseURI function 参数为您的基础 url。

You have to verify your contract source code on etherscan to call functions.您必须在 etherscan 上验证您的合约源代码才能调用函数。 If you don't know how to verify your contract code, then you can deploy your contract through Remix and then you will be able to call contract functions.如果您不知道如何验证您的合约代码,那么您可以通过 Remix 部署您的合约,然后您将能够调用合约函数。

I hope i got the problem and this is the answer.我希望我有问题,这就是答案。

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

相关问题 我不知道如何包括所需的位置参数 - I don't know how to include the required positional arguments 当我直到运行时不知道有多少参数时,在 C 中使用 printf - Using printf in C when I don't know how many arguments until runtime 我正在为R中的函数寻求通配符,但不知道搜索什么? - I'm seeking a wildcard character for my function in R, but don't know what to search? 我不明白的方法参数错误 - Error with method arguments that I don't understand 为什么选择器不需要将 arguments 传递给带参数的方法? - Why don't selectors need to pass arguments to methods that take parameters? C#错误-不包含接受1个参数的构造函数-我不明白我在做什么错? - C#-Error-does not contain a constructor that takes 1 arguments-I don't get what I am doing wrong? 如何获取字符串并将其作为变量…? 我什至不知道该怎么说 - How to take a string and have it as a variable…? I don't even know how to word this 函数中的参数应该是什么,应该返回什么 - What should be my arguments in my function and what should i return 我不太了解有关传递参数的JavaScript语法 - I don't quite get a javascript syntax about passing arguments 如何使用arguments对象从数组中删除元素-我的代码有什么问题? - How to remove elements from an array using arguments object - what's wrong with my code?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM