Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modifier isValidAmount should check for strict equality #7

Open
cleanunicorn opened this issue Aug 8, 2022 · 0 comments
Open

Modifier isValidAmount should check for strict equality #7

cleanunicorn opened this issue Aug 8, 2022 · 0 comments

Comments

@cleanunicorn
Copy link
Member

Description

When a user calls the methods mint or batchMint, they need to provide the correct amount of ether in order to buy the tokens. The ether amount is checked in the modifier isValidAmount.

/**
* @dev Throws if amount is not enough
*
* @param _nftQty quantity of nft to mint
*/
modifier isValidAmount(uint256 _nftQty) {
require(msg.value >= (mintPrice * _nftQty), "Invalid Amount");
_;
}

The check makes sure that the user sent the ether amount that is equal to or higher than the necessary one.

require(msg.value >= (mintPrice * _nftQty), "Invalid Amount");

Recommendation

Change the check to make sure the amount sent is exactly equal to the required amount. Making this change will protect the users from making mistakes and sending too much ether into the contract.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant