简体   繁体   中英

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? It is mainly having issues identifying totalsupply and baseuri. input the below name (string): Test MB symbol (string): 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?

contract TestMB is 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.

To set baseURI, you have to call setBaseURI function with parameter of your base url.

You have to verify your contract source code on etherscan to call functions. 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.

I hope i got the problem and this is the answer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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