0

I want each NFT to cost .02 ETH to mint. There is a constructor uint256 variable called price, but I'm not sure what to do with it since it doesn't correspond to eth.

I just need to know what to add to the 'purchase' function in order to make it cost a certain amount PER nft. Meaning it'll be multiplied if they mint more than 1 in the transaction.

Here is the contract: https://rinkeby.etherscan.io/address/0x3F4d03C071bB0C2B7748417ED03D04C034687013#readContract

1 Answer 1

1

From the purchase function _price is the price of each token in wei.

function purchase(uint numberOfTokens) public payable {
    require(numberOfTokens <= 50, "Can only purchase a maximum of 50");
    require(_price.mul(numberOfTokens) <= msg.value, "Ether value sent is not correct");
    mintToSender(numberOfTokens);
}

If you want each token to cost 0.02 eth then you have to set _price to 0.02 ether.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.