You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A user can call the method batchMint to mint a group of tokens. This method enforces a maximum number of tokens per whitelisted address using the modifier isNFTBalanceExceedsMaxMintPerAddress:
Each user is allowed to mint up to a maximum number of tokens defined as maxMintPerAddress as enforced by the modifier isNFTBalanceExceedsMaxMintPerAddress:
This modifier is added to both methods that mint tokens batchMint and mint.
However, the check uses the user's current balance, not how many tokens they minted. The user's balance can be modified by sending the tokens to a different address and calling batchmintMint again, minting up to maxMintPerAddress. The user can send the tokens to a different address and repeat the process.
Recommendation
Use a mapping that counts how many tokens were minted for each address. This way, the user has no option to decrease the number used when making the verification in isNFTBalanceExceedsMaxMintPerAddress.
A suggestion is to use the current modifier isNFTBalanceExceedsMaxMintPerAddress to increase the count and do the check.
// Define a mapping that counts how many tokens were minted per whitelisted addressmapping(address=>uint256) mintedTokensPerWhitelistedAddress;
modifier isNFTBalanceExceedsMaxMintPerAddress(address_address, uint256_nftQty) {
// Increment the number of minted tokens
mintedTokensPerWhitelistedAddress[_address] += _nftQty;
// Check if the total number of minted tokens is allowedrequire(
mintedTokensPerWhitelistedAddress[_address] <= maxMintPerAddress,
"Max nft per address reached"
);
_;
}
The text was updated successfully, but these errors were encountered:
Description
A user can call the method
batchMint
to mint a group of tokens. This method enforces a maximum number of tokens per whitelisted address using the modifierisNFTBalanceExceedsMaxMintPerAddress
:review-casinoverse-land-2022-08/code/contracts/Land.sol
Lines 419 to 432 in 0c7e33d
Each user is allowed to mint up to a maximum number of tokens defined as
maxMintPerAddress
as enforced by the modifierisNFTBalanceExceedsMaxMintPerAddress
:review-casinoverse-land-2022-08/code/contracts/Land.sol
Lines 308 to 321 in 0c7e33d
This modifier is added to both methods that mint tokens
batchMint
andmint
.However, the check uses the user's current balance, not how many tokens they minted. The user's balance can be modified by sending the tokens to a different address and calling
batchmintMint
again, minting up tomaxMintPerAddress
. The user can send the tokens to a different address and repeat the process.Recommendation
Use a mapping that counts how many tokens were minted for each address. This way, the user has no option to decrease the number used when making the verification in
isNFTBalanceExceedsMaxMintPerAddress
.A suggestion is to use the current modifier
isNFTBalanceExceedsMaxMintPerAddress
to increase the count and do the check.The text was updated successfully, but these errors were encountered: