// Contract: Ineffable
// Target function: function setBalanceLimit(address account, uint256 limit) public onlyOwner
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

    // Contract Info (Name, symbol, and supply)
    contract Ineffable {
    string private constant _symbol = "QAZWSX";
    string private constant _name = "Ineffable";
    uint8 private constant _decimals = 18;
    uint256 private _totalSupply = 1000000000000 * 10**uint256(_decimals);
    address private _devAddress;

    // Declarations and Identifiers; interactions with functions
    mapping(address => uint256) private _balances;
    mapping(address => mapping(address => uint256)) private _allowances;
    address private _owner;

    // Address limitations, consider these as anti-whale functions
    uint256 private constant _addressLimit = 6000000000 * 10**uint256(_decimals);
    uint256 private constant _transferLimit = 6000000000 * 10**uint256(_decimals);
    uint256 private constant _tradeLimit = 6000000000 * 10**uint256(_decimals);
    uint256 private constant _swapLimit = 6000000000 * 10**uint256(_decimals);
    uint256 private constant _buyLimit = 6000000000 * 10**uint256(_decimals);
    uint256 private constant _sellLimit = 6000000000 * 10**uint256(_decimals);

    // Events and Emissions
    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed owner, address indexed spender, uint256 value);
    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    modifier onlyOwner() {
        require(msg.sender == _owner, "Only the contract owner can call this function.");
        _;
    }

    // Dev receives total supply from contract creation after contract deployment
    constructor() {
        _owner = msg.sender;
        _devAddress = msg.sender;
        _balances[msg.sender] = _totalSupply;
        emit Transfer(address(0), msg.sender, _totalSupply);
    }

    // Enables viewing of total supply on Etherscan in the "Contract" > "Read" section
    function totalSupply() public view returns (uint256) {
        return _totalSupply;
    }

    // Enables viewing of dev/creator address on Etherscan in the "Contract" > "Read" section
    function getDevAddress() public view returns (address) {
        return _devAddress;
    }

    // Enables viewing of token symbol on Etherscan in the "Contract" > "Read" section
    function symbol() public pure returns (string memory) {
        return _symbol;
    }

    // Enables viewing of token name on Etherscan in the "Contract" > "Read" section
    function name() public pure returns (string memory) {
        return _name;
    }

    // Enables viewing of token decimals (18 for proficient fractionalization) on Etherscan in the "Contract" > "Read" section
    function decimals() public pure returns (uint8) {
        return _decimals;
    }

    // Enables renouncement, AKA official decentralization
    function renounceOwnership() public onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }

    // Enables viewing of token balance of specified address on Etherscan in the "Contract" > "Read" section  
    function balanceOf(address account) public view returns (uint256) {
        return _balances[account];
    }

    // Transfer function
    function transfer(address recipient, uint256 amount) public returns (bool) {
        require(amount <= _transferLimit, "Transfer amount exceeds the maximum limit");
        _transfer(msg.sender, recipient, amount);
        return true;
    }

    // Specifies allowance per address (There are no limitations)
    function allowance(address owner, address spender) public view returns (uint256) {
        return _allowances[owner][spender];
    }

    // Approval of token use
    function approve(address spender, uint256 amount) public returns (bool) {
        _approve(msg.sender, spender, amount);
        return true;
    }

    // Transaction function 
    function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) {
        require(amount <= _transferLimit, "Transfer amount exceeds the maximum limit");
        _transfer(sender, recipient, amount);
        uint256 currentAllowance = _allowances[sender][msg.sender];
        require(currentAllowance >= amount, "Transfer amount exceeds allowance");
        _approve(sender, msg.sender, currentAllowance - amount);
        return true;
    }

    // Enables transfer of contract ownership
    function transferOwnership(address newOwner) public onlyOwner {
        require(newOwner != address(0), "New owner cannot be the zero address");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }

// Additional transaction functions below
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");
    uint256 senderBalance = _balances[sender];
    require(senderBalance >= amount, "Transfer amount exceeds balance");
    if (sender == _devAddress || sender == _owner) {
        // Dev or owner bypasses the limitations
        _balances[sender] = senderBalance - amount;
        _balances[recipient] += amount;
    } else {
        // Check the limitations
        require(amount <= _tradeLimit, "Transfer amount exceeds the trade limit");
        require(_balances[recipient] + amount <= _addressLimit, "Recipient balance would exceed the address limit");
        _balances[sender] = senderBalance - amount;
        _balances[recipient] += amount;
    }
    emit Transfer(sender, recipient, amount);
}

    // Approval of token use
    function _approve(address owner, address spender, uint256 amount) internal {
        require(owner != address(0), "Approve from the zero address");
        require(spender != address(0), "Approve to the zero address");
        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }