contract RFIEXTREMECollectible is Ownable, ERC721 {

    uint256 _tokenIds = 0;


    
    uint256 rfiprice = 50 ether;


    uint256 maxmint = 50;


    mapping (address =>  bool) public whitelist;


    IERC20 public _rfiextremetoken;


    address daoAddress;

   



    constructor(string memory baseURI_) ERC721("RFIEXTRE.ME Whale Collectible", "RFIEWC") public {

        _setBaseURI(baseURI_);

        _rfiextremetoken = IERC20(address(0x1Fd13b3508802aDDE7D3389337EBEB950FF358C4));
    }


  
    function setWhitelist(address _address, bool status) external onlyOwner() {
        whitelist[_address] = status;
    }



    function setDao(address _dao) external onlyOwner() {

        daoAddress = _dao;
    }



    function awardItem(address receiver/*, string memory tokenUR*/) internal returns (bool) {
        
        require(_tokenIds < maxmint, "Minting over");

        uint256 newItemId = _tokenIds;
        _mint(receiver, newItemId);
        //_setTokenURI(newItemId, tokenURI);

        _tokenIds = _tokenIds.add(1);




        return true;
    }



    function mint() external {

        //check whitelist

        if(whitelist[_msgSender()]){

            whitelist[_msgSender()] = false;

        }else{

            //require the token amount, we are cool so we are not taking the 12% fees in consideration
            require(_rfiextremetoken.transferFrom(_msgSender(), address(this), rfiprice) );

        }
        //require it
        require(awardItem(_msgSender()));



    }


    function moveToLock() public {


        uint256 rfibalance = _rfiextremetoken.balanceOf(address(this));

   

        if(daoAddress != address(0)){
            
          
            require(_rfiextremetoken.transfer(address(daoAddress),rfibalance));
            
            
            
        }

    }





    function safeTransferFrom(address from, address to, uint256 tokenId)  public virtual override {

               safeTransferFrom(from, to, tokenId, "");
           }

    /**
    * @dev See {IERC721-safeTransferFrom}.
    */
    function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data)  public virtual override {


        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
        
        _safeTransfer(from, to, tokenId, _data);
    }


    /**
    * @dev See {IERC721-transferFrom}.
*/
    function transferFrom(address from, address to, uint256 tokenId)  public virtual override {
        //solhint-disable-next-line max-line-length
           
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
      
        _transfer(from, to, tokenId);
    }





}
function transferFrom(address from, address to, uint256 tokenId)  public virtual override {
    //solhint-disable-next-line max-line-length
           
    require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
      
    _transfer(from, to, tokenId);
}

/**
 * @dev See {IERC721-transferFrom}.
 */