// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

contract MyToken {
    string public name = "SIGMA TOKEN";
    string public symbol = "SIGMA";
    uint256 public totalSupply = 0.0000000001 * 10**18; // 100 million tokens with 18 decimal places
    uint256 public maxTxAmount = totalSupply / 20; // 2% of the total supply
    uint256 public maxWalletAmount = totalSupply / 20; // 2% of the total supply
    uint256 public taxFee = 5; // 5% tax fee
    uint256 public taxFeeDivider = 100; // 100 = 100%
    address public marketingWallet;

    mapping (address => uint256) private balances;
    mapping (address => mapping (address => uint256)) private allowances;

    event Transfer(address indexed from, address indexed to, uint256 amount);
    event Approval(address indexed owner, address indexed spender, uint256 amount);
    event MarketingWalletUpdated(address indexed oldMarketingWallet, address indexed newMarketingWallet);
    event MaxTxAmountUpdated(uint256 oldMaxTxAmount, uint256 newMaxTxAmount);
    event MaxWalletAmountUpdated(uint256 oldMaxWalletAmount, uint256 newMaxWalletAmount);
 

    modifier onlyMarketingWallet() {
        require(msg.sender == marketingWallet, "Only the marketing wallet can call this function.");
        _;
    }

   

    constructor(address _marketingWallet) {
        marketingWallet = _marketingWallet;
        balances[_marketingWallet] = totalSupply;
        emit Transfer(address(0), _marketingWallet, totalSupply);
    }

  

    function setMarketingWallet(address _marketingWallet) public onlyMarketingWallet {
        require(_marketingWallet != address(0), "Marketing wallet cannot be the zero address.");
        emit MarketingWalletUpdated(marketingWallet, _marketingWallet);
        balances[_marketingWallet] = balances[marketingWallet];
        balances[marketingWallet] = 0;
        marketingWallet = _marketingWallet;
    }

    function setMaxTxAmount(uint256 _maxTxAmount) public onlyMarketingWallet {
        emit MaxTxAmountUpdated(maxTxAmount, _maxTxAmount);
        maxTxAmount = _maxTxAmount;
    }

    function setMaxWalletAmount(uint256 _maxWalletAmount) public onlyMarketingWallet {
        emit MaxWalletAmountUpdated(maxWalletAmount, _maxWalletAmount);
        maxWalletAmount = _maxWalletAmount;
    }

    function _transfer(address sender, address recipient, uint256 amount) internal {
        require(sender != address(0), "Transfer from the zero address.");
        require(recipient != address(0), "Transfer to the zero address.");
        require(amount > 0, "Transfer amount must be greater than zero.");
        require(amount <= maxTxAmount, "Transfer amount exceeds the maximum transaction amount.");
        require(balances[sender] >= amount, "Insufficient balance.");

        uint256 taxAmount = amount * taxFee / taxFeeDivider;
        uint256 transferAmount = amount - taxAmount;

        balances[sender] -= amount;
        balances[recipient] += transferAmount;
        balances[marketingWallet] += taxAmount;

        emit Transfer(sender, recipient, transferAmount);
        emit Transfer(sender, marketingWallet, taxAmount);
}

function balanceOf(address account) public view returns (uint256) {
    return balances[account];
}

function approve(address spender, uint256 amount) public returns (bool) {
    require(spender != address(0), "Approve to the zero address.");
    require(amount > 0, "Approval amount must be greater than zero.");

    allowances[msg.sender][spender] = amount;

    emit Approval(msg.sender, spender, amount);
    return true;
}

function allowance(address owner, address spender) public view returns (uint256) {
    return allowances[owner][spender];
}

function transfer(address recipient, uint256 amount) public returns (bool) {
    _transfer(msg.sender, recipient, amount);
    return true;
}

function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) {
    require(amount <= allowances[sender][msg.sender], "Transfer amount exceeds allowance.");

    allowances[sender][msg.sender] -= amount;
    _transfer(sender, recipient, amount);

    return true;
}

}