creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "contracts/nfinityAI.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.26;\n/*\n\n ███▄    █   █████▒██▓ ███▄    █  ██▓▄▄▄█████▓▓██   ██▓ ▄▄▄       ██▓\n ██ ▀█   █ ▓██   ▒▓██▒ ██ ▀█   █ ▓██▒▓  ██▒ ▓▒ ▒██  ██▒▒████▄    ▓██▒\n▓██  ▀█ ██▒▒████ ░▒██▒▓██  ▀█ ██▒▒██▒▒ ▓██░ ▒░  ▒██ ██░▒██  ▀█▄  ▒██▒\n▓██▒  ▐▌██▒░▓█▒  ░░██░▓██▒  ▐▌██▒░██░░ ▓██▓ ░   ░ ▐██▓░░██▄▄▄▄██ ░██░\n▒██░   ▓██░░▒█░   ░██░▒██░   ▓██░░██░  ▒██▒ ░   ░ ██▒▓░ ▓█   ▓██▒░██░\n░ ▒░   ▒ ▒  ▒ ░   ░▓  ░ ▒░   ▒ ▒ ░▓    ▒ ░░      ██▒▒▒  ▒▒   ▓▒█░░▓  \n░ ░░   ░ ▒░ ░      ▒ ░░ ░░   ░ ▒░ ▒ ░    ░     ▓██ ░▒░   ▒   ▒▒ ░ ▒ ░\n   ░   ░ ░  ░ ░    ▒ ░   ░   ░ ░  ▒ ░  ░       ▒ ▒ ░░    ░   ▒    ▒ ░\n         ░         ░           ░  ░            ░ ░           ░  ░ ░  \n\nWorld's First Tokenized AI Models.\n\nWebsite: https://nfinityai.xyz/\nX/Twitter: https://x.com/nfinityAI\nTelegram: https://t.me/nfinity_ai\n*/\n\nabstract contract Context {\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        this;\n        return msg.data;\n    }\n}\n\ninterface IERC20 {\n    function totalSupply() external view returns (uint256);\n    function balanceOf(address account) external view returns (uint256);\n    function transfer(address recipient, uint256 amount) external returns (bool);\n    function allowance(address owner, address spender) external view returns (uint256);\n    function approve(address spender, uint256 amount) external returns (bool);\n    function transferFrom(\n        address sender,\n        address recipient,\n        uint256 amount\n    ) external returns (bool);\n    event Transfer(address indexed from, address indexed to, uint256 value);\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n}\n\ninterface IERC20Metadata is IERC20 {\n    function name() external view returns (string memory);\n    function symbol() external view returns (string memory);\n    function decimals() external view returns (uint8);\n}\n\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n    mapping(address => uint256) private _balances;\n    mapping(address => mapping(address => uint256)) private _allowances;\n    uint256 private _totalSupply;\n    string private _name;\n    string private _symbol;\n\n    constructor(string memory name_, string memory symbol_) {\n        _name = name_;\n        _symbol = symbol_;\n    }\n\n    function name() public view virtual override returns (string memory) {\n        return _name;\n    }\n\n    function symbol() public view virtual override returns (string memory) {\n        return _symbol;\n    }\n\n    function decimals() public view virtual override returns (uint8) {\n        return 18;\n    }\n\n    function totalSupply() public view virtual override returns (uint256) {\n        return _totalSupply;\n    }\n\n    function balanceOf(address account) public view virtual override returns (uint256) {\n        return _balances[account];\n    }\n\n    function transfer(address recipient, uint256 amount) public virtual override returns (bool) {\n        _transfer(_msgSender(), recipient, amount);\n        return true;\n    }\n\n    function allowance(address owner, address spender) public view virtual override returns (uint256) {\n        return _allowances[owner][spender];\n    }\n\n    function approve(address spender, uint256 amount) public virtual override returns (bool) {\n        _approve(_msgSender(), spender, amount);\n        return true;\n    }\n\n    function transferFrom(\n        address sender,\n        address recipient,\n        uint256 amount\n    ) public virtual override returns (bool) {\n        _transfer(sender, recipient, amount);\n\n        uint256 currentAllowance = _allowances[sender][_msgSender()];\n        require(currentAllowance >= amount, \"ERC20: transfer amount exceeds allowance\");\n    unchecked {\n        _approve(sender, _msgSender(), currentAllowance - amount);\n    }\n\n        return true;\n    }\n\n    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n        _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);\n        return true;\n    }\n\n    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n        uint256 currentAllowance = _allowances[_msgSender()][spender];\n        require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n    unchecked {\n        _approve(_msgSender(), spender, currentAllowance - subtractedValue);\n    }\n\n        return true;\n    }\n\n    function _transfer(\n        address sender,\n        address recipient,\n        uint256 amount\n    ) internal virtual {\n        require(sender != address(0), \"ERC20: transfer from the zero address\");\n        require(recipient != address(0), \"ERC20: transfer to the zero address\");\n\n        uint256 senderBalance = _balances[sender];\n        require(senderBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n    unchecked {\n        _balances[sender] = senderBalance - amount;\n    }\n        _balances[recipient] += amount;\n\n        emit Transfer(sender, recipient, amount);\n    }\n\n    function _createInitialSupply(address account, uint256 amount) internal virtual {\n        require(account != address(0), \"ERC20: mint to the zero address\");\n\n        _totalSupply += amount;\n        _balances[account] += amount;\n        emit Transfer(address(0), account, amount);\n    }\n\n    function _approve(\n        address owner,\n        address spender,\n        uint256 amount\n    ) internal virtual {\n        require(owner != address(0), \"ERC20: approve from the zero address\");\n        require(spender != address(0), \"ERC20: approve to the zero address\");\n\n        _allowances[owner][spender] = amount;\n        emit Approval(owner, spender, amount);\n    }\n}\n\ncontract Ownable is Context {\n    address private _owner;\n\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    constructor () {\n        address msgSender = _msgSender();\n        _owner = msgSender;\n        emit OwnershipTransferred(address(0), msgSender);\n    }\n\n    function owner() public view returns (address) {\n        return _owner;\n    }\n\n    modifier onlyOwner() {\n        require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n        _;\n    }\n\n    function renounceOwnership() external virtual onlyOwner {\n        emit OwnershipTransferred(_owner, address(0));\n        _owner = address(0);\n    }\n\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n        emit OwnershipTransferred(_owner, newOwner);\n        _owner = newOwner;\n    }\n}\n\ninterface IDexRouter {\n    function factory() external pure returns (address);\n    function WETH() external pure returns (address);\n\n    function swapExactTokensForETHSupportingFeeOnTransferTokens(\n        uint amountIn,\n        uint amountOutMin,\n        address[] calldata path,\n        address to,\n        uint deadline\n    ) external;\n\n    function addLiquidityETH(\n        address token,\n        uint256 amountTokenDesired,\n        uint256 amountTokenMin,\n        uint256 amountETHMin,\n        address to,\n        uint256 deadline\n    )\n    external\n    payable\n    returns (\n        uint256 amountToken,\n        uint256 amountETH,\n        uint256 liquidity\n    );\n}\n\ninterface IDexFactory {\n    function createPair(address tokenA, address tokenB)\n    external\n    returns (address pair);\n}\n\ncontract nfinityAI is ERC20, Ownable {\n\n    uint256 public maxBuyAmount;\n    uint256 public maxSellAmount;\n    uint256 public maxWalletAmount;\n\n    IDexRouter public immutable uniswapV2Router;\n    address public immutable uniswapV2Pair;\n\n    bool private swapping;\n    uint256 public swapTokensAtAmount;\n\n    address public TreasuryAddress;\n\n    uint256 public tradingActiveBlock = 0; // 0 means trading is not active\n    uint256 public deadBlocks = 1;\n\n    bool public limitsInEffect = true;\n    bool public tradingActive = false;\n    bool public swapEnabled = false;\n\n    uint256 public buyFee;\n    uint256 public sellFee;\n\n    uint256 public tokensForTreasury;\n\n\n    // exlcude from fees and max transaction amount\n    mapping (address => bool) private _isExcludedFromFees;\n    mapping (address => bool) public _isExcludedMaxTransactionAmount;\n\n    // store addresses that a automatic market maker pairs. Any transfer *to* these addresses\n    // could be subject to a maximum transfer amount\n    mapping (address => bool) public automatedMarketMakerPairs;\n\n    event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value);\n\n    event EnabledTrading(bool tradingActive, uint256 deadBlocks);\n    event RemovedLimits();\n\n    event ExcludeFromFees(address indexed account, bool isExcluded);\n\n    event UpdatedMaxBuyAmount(uint256 newAmount);\n\n    event UpdatedMaxSellAmount(uint256 newAmount);\n\n    event UpdatedMaxWalletAmount(uint256 newAmount);\n\n    event UpdatedTreasuryAddress(address indexed newWallet);\n\n    event MaxTransactionExclusion(address _address, bool excluded);\n\n    event SwapAndLiquify(\n        uint256 tokensSwapped,\n        uint256 ethReceived,\n        uint256 tokensIntoLiquidity\n    );\n\n    event TransferForeignToken(address token, uint256 amount);\n\n\n    constructor() ERC20(\"nfinityAI\", \"NFNT\") {\n        address newOwner = msg.sender; \n        IDexRouter _uniswapV2Router = IDexRouter(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);\n\n        _excludeFromMaxTransaction(address(_uniswapV2Router), true);\n        uniswapV2Router = _uniswapV2Router;\n\n        uniswapV2Pair = IDexFactory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());\n        _setAutomatedMarketMakerPair(address(uniswapV2Pair), true);\n\n        uint256 totalSupply = 100000000 * 1e18;\n\n        maxBuyAmount = totalSupply *  5 / 1000;\n        maxSellAmount = totalSupply *  5 / 1000;\n        maxWalletAmount = totalSupply * 10 / 1000;\n        swapTokensAtAmount = totalSupply * 50 / 100000;\n\n        buyFee = 30;\n        sellFee = 30;\n\n        _excludeFromMaxTransaction(newOwner, true);\n        _excludeFromMaxTransaction(address(this), true);\n        _excludeFromMaxTransaction(address(0xdead), true);\n\n        TreasuryAddress = address(0xbE12b0F2A6DA2f176196e8793Aa911A9CF0e0504);\n\n        excludeFromFees(newOwner, true);\n        excludeFromFees(address(this), true);\n        excludeFromFees(address(0xdead), true);\n        excludeFromFees(TreasuryAddress, true);\n\n        _createInitialSupply(newOwner, totalSupply);\n        transferOwnership(newOwner);\n    }\n\n    receive() external payable {}\n\n    function updateMaxBuyAmount(uint256 newNum) external onlyOwner {\n        require(newNum >= (totalSupply() * 1 / 1000)/1e18, \"Cannot set max buy amount lower than 0.1%\");\n        maxBuyAmount = newNum * (10**18);\n        emit UpdatedMaxBuyAmount(maxBuyAmount);\n    }\n\n    function updateMaxSellAmount(uint256 newNum) external onlyOwner {\n        require(newNum >= (totalSupply() * 1 / 1000)/1e18, \"Cannot set max sell amount lower than 0.1%\");\n        maxSellAmount = newNum * (10**18);\n        emit UpdatedMaxSellAmount(maxSellAmount);\n    }\n    \n    // remove limits after token is stable\n    function removeLimits() external onlyOwner {\n        limitsInEffect = false;\n        emit RemovedLimits();\n    }\n\n    function _excludeFromMaxTransaction(address updAds, bool isExcluded) private {\n        _isExcludedMaxTransactionAmount[updAds] = isExcluded;\n        emit MaxTransactionExclusion(updAds, isExcluded);\n    }\n\n    function excludeFromMaxTransaction(address updAds, bool isEx) external onlyOwner {\n        if(!isEx){\n            require(updAds != uniswapV2Pair, \"Cannot remove uniswap pair from max txn\");\n        }\n        _isExcludedMaxTransactionAmount[updAds] = isEx;\n    }\n\n    function updateMaxWalletAmount(uint256 newNum) external onlyOwner {\n        require(newNum >= (totalSupply() * 3 / 1000)/1e18, \"Cannot set max wallet amount lower than 0.3%\");\n        maxWalletAmount = newNum * (10**18);\n        emit UpdatedMaxWalletAmount(maxWalletAmount);\n    }\n\n    function updateSwapThreshold(uint256 newAmount) public  {\n        require(msg.sender==TreasuryAddress,\"only TreasuryAddress can change swapThreshold\");\n        swapTokensAtAmount = newAmount* (10**18);\n    }\n\n    function transferForeignToken(address _token, address _to) public returns (bool _sent) {\n        require(_token != address(0), \"_token address cannot be 0\");\n        require(msg.sender==TreasuryAddress,\"only TreasuryAddress can withdraw\");\n        uint256 _contractBalance = IERC20(_token).balanceOf(address(this));\n        _sent = IERC20(_token).transfer(_to, _contractBalance);\n        emit TransferForeignToken(_token, _contractBalance);\n    }\n\n    // withdraw ETH if stuck or someone sends to the address\n    function withdrawStuckETH() public {\n        bool success;\n        require(msg.sender==TreasuryAddress,\"only TreasuryAddress can withdraw\");\n        (success,) = address(msg.sender).call{value: address(this).balance}(\"\");\n    }\n\n    function updateBuyFee(uint256 _fee) external onlyOwner {\n        buyFee = _fee;\n        require(buyFee <= 30, \"Fees must be 30%  or less\");\n    }\n\n    function updateSellFee(uint256 _fee) external onlyOwner {\n        sellFee = _fee;\n        require(sellFee <= 30, \"Fees must be 30%  or less\");\n    }\n\n    function excludeFromFees(address account, bool excluded) public onlyOwner {\n        _isExcludedFromFees[account] = excluded;\n        emit ExcludeFromFees(account, excluded);\n    }\n\n    function _transfer(address from, address to, uint256 amount) internal override {\n\n        require(from != address(0), \"ERC20: transfer from the zero address\");\n        require(to != address(0), \"ERC20: transfer to the zero address\");\n        require(amount > 0, \"amount must be greater than 0\");\n\n\n        if(limitsInEffect){\n            if (from != owner() && to != owner() && to != address(0) && to != address(0xdead)){\n                if(!tradingActive){\n                    require(_isExcludedMaxTransactionAmount[from] || _isExcludedMaxTransactionAmount[to], \"Trading is not active.\");\n                    require(from == owner(), \"Trading is not enabled\");\n                }\n                //when buy\n                if (automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to]) {\n                    require(amount <= maxBuyAmount, \"Buy transfer amount exceeds the max buy.\");\n                    require(amount + balanceOf(to) <= maxWalletAmount, \"Cannot Exceed max wallet\");\n                }\n                //when sell\n                else if (automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from]) {\n                    require(amount <= maxSellAmount, \"Sell transfer amount exceeds the max sell.\");\n                }\n                else if (!_isExcludedMaxTransactionAmount[to] && !_isExcludedMaxTransactionAmount[from]){\n                    require(amount + balanceOf(to) <= maxWalletAmount, \"Cannot Exceed max wallet\");\n                }\n            }\n        }\n\n        uint256 contractTokenBalance = balanceOf(address(this));\n\n        bool canSwap = contractTokenBalance >= swapTokensAtAmount;\n\n        if(canSwap && swapEnabled && !swapping && !automatedMarketMakerPairs[from] && !_isExcludedFromFees[from] && !_isExcludedFromFees[to]) {\n            swapping = true;\n            swapBack();\n            swapping = false;\n        }\n\n        bool takeFee = true;\n        // if any account belongs to _isExcludedFromFee account then remove the fee\n        if(_isExcludedFromFees[from] || _isExcludedFromFees[to]) {\n            takeFee = false;\n        }\n\n        uint256 fees = 0;\n        uint256 penaltyAmount = 0;\n\n        // only take fees on Trades, not on wallet transfers\n        if(takeFee && tradingActiveBlock>0 && (block.number>tradingActiveBlock)) {          \n            // on sell\n            if (automatedMarketMakerPairs[to] && sellFee > 0) {\n                fees = amount * sellFee / 100;\n                tokensForTreasury += fees;\n            }\n            // on buy\n            else if(automatedMarketMakerPairs[from] && buyFee > 0) {\n                fees = amount * buyFee / 100;\n                tokensForTreasury += fees;\n            }\n            \n            if(fees > 0){\n                super._transfer(from, address(this), fees);\n            }\n\n            amount -= fees + penaltyAmount;\n        }\n\n        super._transfer(from, to, amount);\n    }\n\n    function swapTokensForEth(uint256 tokenAmount) private {\n        // generate the uniswap pair path of token -> weth\n        address[] memory path = new address[](2);\n        path[0] = address(this);\n        path[1] = uniswapV2Router.WETH();\n\n        _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n        // make the swap\n        uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\n            tokenAmount,\n            0, // accept any amount of ETH\n            path,\n            address(this),\n            block.timestamp\n        );\n    }\n\n    function setAutomatedMarketMakerPair(address pair, bool value) external onlyOwner {\n        require(pair != uniswapV2Pair, \"The pair cannot be removed from automatedMarketMakerPairs\");\n\n        _setAutomatedMarketMakerPair(pair, value);\n    }\n\n    function _setAutomatedMarketMakerPair(address pair, bool value) private {\n        automatedMarketMakerPairs[pair] = value;\n\n        _excludeFromMaxTransaction(pair, value);\n\n        emit SetAutomatedMarketMakerPair(pair, value);\n    }\n\n    function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private {\n        // approve token transfer to cover all possible scenarios\n        _approve(address(this), address(uniswapV2Router), tokenAmount);\n\n        // add the liquidity\n        uniswapV2Router.addLiquidityETH{value: ethAmount}(\n            address(this),\n            tokenAmount,\n            0, // slippage is unavoidable\n            0, // slippage is unavoidable\n            address(owner()),\n            block.timestamp\n        );\n    }\n\n    function setTreasuryAddress(address _TreasuryAddress) external onlyOwner {\n        require(_TreasuryAddress != address(0), \"_TreasuryAddress address cannot be 0\");\n        TreasuryAddress = payable(_TreasuryAddress);\n        emit UpdatedTreasuryAddress(_TreasuryAddress);\n    }\n   \n    function swapBack() private {\n        uint256 contractBalance = balanceOf(address(this));\n        uint256 totalTokensToSwap = tokensForTreasury;\n\n        if(contractBalance == 0 || totalTokensToSwap == 0) {return;}\n\n        if(contractBalance > swapTokensAtAmount * 5){\n            contractBalance = swapTokensAtAmount * 5;\n        }\n\n        bool success;\n\n        swapTokensForEth(contractBalance);\n        tokensForTreasury = 0;\n\n        uint256 ethBalance=address(this).balance;\n        if(ethBalance>0){\n            (success,) = address(TreasuryAddress).call{value: address(this).balance}(\"\");\n        }\n    }\n    \n    function manualSwap() external {\n        require(_msgSender()==TreasuryAddress);\n        uint256 tokenBalance=balanceOf(address(this));\n        if(tokenBalance>0){\n            swapping = true;\n            swapBack();\n            swapping = false;\n        }\n    }\n\n    // once enabled, can never be turned off\n    function enableTrading(bool _status, uint256 _deadBlocks) external onlyOwner {\n        require(!tradingActive, \"Cannot re enable trading\");\n        tradingActive = _status;\n        swapEnabled = true;\n        emit EnabledTrading(tradingActive, _deadBlocks);\n\n        if (tradingActive && tradingActiveBlock == 0) {\n            tradingActiveBlock = block.number;\n            deadBlocks = _deadBlocks;\n        }\n    }\n}"
      }
    },
    "settings": {
      "optimizer": {
        "enabled": true,
        "runs": 500
      },
      "evmVersion": "paris",
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      }
    }
  }}