contract bannermfers is ERC721, Ownable {

    address public MFERS_ADDRESS;
    address payable public payments;
    IERC721 private _mfersContract;

    uint private _totalSupply;

    string private _metadataBaseURI;
    string private _metadataExtension;

    uint public cost = 0.0169 ether;

    /* events */
    event Received(address,  uint);

    /* metadata */

    constructor(address mfersAddress, address _payments) ERC721("banner mfers", "bannermfer") Ownable() {
        setMfersAddress(mfersAddress);
        setMetadataBaseURI("https://gateway.pinata.cloud/ipfs/QmQoBpkMvrpuegnUvmp6jGg1xschRnvyMAi4YjMKrw9fn4/");
        setMetadataExtenstion(".json");
        payments = payable(_payments);
    }

    receive() external payable {
        emit Received(msg.sender, msg.value);
    }

    /* owner's functions */

    function setMfersAddress(address newAddress) public onlyOwner {
        MFERS_ADDRESS = newAddress;
        _mfersContract = IERC721(MFERS_ADDRESS);
    }

    function setMetadataBaseURI(string memory uri) public onlyOwner {
        _metadataBaseURI = uri;
    }

    function setMetadataExtenstion(string memory extension) public onlyOwner {
        _metadataExtension = extension;
    }

    function withdraw() public onlyOwner {
        (bool sent,) = payable(payments).call{value: address(this).balance}("");
        require(sent, "Failed to send Ether");
    }

    /* Public functions */

    function _mint(uint256 token) private {
        require(msg.value >= cost, "Price is 0.0169 Eth");
        require(_mfersContract.ownerOf(token) == msg.sender, "You need to own the mfer");

        _safeMint(msg.sender, token);

        _totalSupply += 1;
    }

    function mint(uint256 token) payable public {
        emit Received(msg.sender, msg.value);

        _mint(token);
    }

    function massMint(uint256[] memory tokens) payable public {
        require(msg.value >= (cost * tokens.length), "Price is 0.0169 Eth per banner");
        for (uint i = 0; i < tokens.length; ++i)
        {
            require(_mfersContract.ownerOf(tokens[i]) == msg.sender, "You need to own the mfer");
            _mint(tokens[i]);
        }
    }

    function totalSupply() public view returns(uint supply)
    {
        supply = _totalSupply;
    }

    function tokenURI(uint256 token) public view override(ERC721) returns(string memory)
    {
        return string(abi.encodePacked(_metadataBaseURI, Strings.toString(token), _metadataExtension));
    }
}
function _mint(uint256 token) private {
    require(msg.value >= cost, "Price is 0.0169 Eth");
    require(_mfersContract.ownerOf(token) == msg.sender, "You need to own the mfer");

    _safeMint(msg.sender, token);

    _totalSupply += 1;
}

/* Public functions */