CRYPTO NEWS

Function Max mint per wallet is not working

learning solidity and curious how i can limit the minting of my NFT to only 2 per wallet address. Trying to prevent people from minting more then 2 tokens during free mint phase using "mapping" but is not working.

pragma solidity >=0.8.9 <0.9.0;  import 'erc721a/contracts/extensions/ERC721AQueryable.sol'; import '@openzeppelin/contracts/access/Ownable.sol'; import '@openzeppelin/contracts/utils/cryptography/MerkleProof.sol'; import '@openzeppelin/contracts/security/ReentrancyGuard.sol';  contract DD is ERC721AQueryable, Ownable, ReentrancyGuard {    using Strings for uint256;    string public baseURI = '';   string public uriSuffix = '.json';      uint256 public cost;   uint256 public maxSupply;   uint256 public maxFreeMint = 4;   uint256 public maxMintAmountPerWallet = 2;    mapping(address => uint256) private _freeWalletMints;    bool public paused = true;    constructor(     string memory _tokenName,     string memory _tokenSymbol,     uint256 _cost,     uint256 _maxSupply   ) ERC721A(_tokenName, _tokenSymbol) {     setCost(_cost);     maxSupply = _maxSupply;   }    modifier mintCompliance(uint256 _mintAmount) {      require(_mintAmount > 0, 'Invalid mint amount!');     require(totalSupply() + _mintAmount <= maxSupply, 'Max supply exceeded!');      _;   }     function mint(uint256 _mintAmount) public payable mintCompliance(_mintAmount){     if(msg.sender != owner()){       require(!paused, 'The contract is paused!');       require(_freeWalletMints[_msgSender()] + _mintAmount <= 2, 'You have already minted');       if (totalSupply()+_mintAmount > maxFreeMint){           require(msg.value >= cost * _mintAmount, "Insufficient funds!");         }       }       _safeMint(_msgSender(), _mintAmount);     }    function _startTokenId() internal view virtual override returns (uint256) {     return 1;   }    function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) {     require(_exists(_tokenId), 'ERC721Metadata: URI query for nonexistent token');      string memory currentBaseURI = _baseURI();     return bytes(currentBaseURI).length > 0         ? string(abi.encodePacked(currentBaseURI, _tokenId.toString(), uriSuffix))         : '';   }    function setCost(uint256 _cost) public onlyOwner {     cost = _cost;   }   function setBaseURI(string memory _url) public onlyOwner {     baseURI = _url;   }    function setUriSuffix(string memory _uriSuffix) public onlyOwner {     uriSuffix = _uriSuffix;   }    function setPaused(bool _state) public onlyOwner {     paused = _state;   }    function withdraw() public onlyOwner nonReentrant {     (bool os, ) = payable(owner()).call{value: address(this).balance}('');     require(os);   }    function _baseURI() internal view virtual override returns (string memory) {     return baseURI;   } } 

re-entrancy vulnerability – "Potential violation of Checks-Effects-Interaction pattern"

I am getting the error "Potential violation of Checks-Effects-Interaction pattern in Test.treasuryLock(address,uint256): Could potentially lead to re-entrancy vulnerability." But I am not really sure why, I even add a require check for rentrancym, but I still get the same error. Do you have any ideea? bool isTransferring = false; // Lock treasury // This function::Listen

I am getting the error "Potential violation of Checks-Effects-Interaction pattern in Test.treasuryLock(address,uint256): Could potentially lead to re-entrancy vulnerability." But I am not really sure why, I even add a require check for rentrancym, but I still get the same error. Do you have any ideea?

bool isTransferring = false; // Lock treasury // This function may be called only by the token contractor address  event treasuryLockEvent(address,uint256); function treasuryLock(     address _beneficiary,     uint256 amount ) public returns(     string memory,      uint256,      string memory,      address     ) {      require(isTransferring == false, "Rentrancy Detected");     isTransferring = true;     require( _beneficiary != address(0), "Please insert the beneficiary address.");     address from = _msgSender();     require( from == getTokenAddressContractor(), "Only token address contractor can lock Treasury.");     require(from != burnAddress, "Burn address can not lock treasury." );      if (_contractLink[_beneficiary] == newContract)         _contractLink[_beneficiary] = new LockTest(token,_beneficiary);      _transfer(from, _contractLink[_beneficiary].getAddress() ,amount);     _lockedTreasury[_beneficiary]=balanceOf(_contractLink[_beneficiary].getAddress());     isTransferring = false;     emit treasuryLockEvent(_beneficiary,amount);      return (         "Existing contract received amount:",         amount,       "Beneficiary address:",       _beneficiary     );      } 

Function Max mint per wallet is not working

Shopping cart
There are no products in the cart!
Continue shopping
0