[英]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.