Skip to content
Verified contractPartialMIT

NYAN

Address0x9e2c75cba66d3d821768ba68c4b331bd4344a157
Balance

0 ETH

 

Transactions

11

 

Compiler

solc 0.8.20

 

Same code

9 more contracts

 

Details

Compiler
solc 0.8.20+commit.a1b79de6
Language
solidity
Optimization
Yes, 200 runs
EVM version
paris
License
MIT
Match
Partialcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
24,924,813
Creation transaction
0x709628dac2…0d8a8c7a78
Main copy (most transactions)
0xb9139005…7c294fa1

NYAN.sol

// SPDX-License-Identifier: MIT
/*
 * Nyan Cat
 * All fees (2%/2%) go directly to PRguitarman, creator of Nyan Cat.
 * https://x.com/0xnyancat
 */

pragma solidity ^0.8.20;

interface IUniswapV2Router02 {
    function factory() external pure returns (address);
    function WETH() external pure returns (address);
    function swapExactTokensForETHSupportingFeeOnTransferTokens(
        uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline
    ) external;
    function addLiquidityETH(
        address token, uint amountTokenDesired, uint amountTokenMin,
        uint amountETHMin, address to, uint deadline
    ) external payable returns (uint amountToken, uint amountETH, uint liquidity);
}

interface IUniswapV2Factory {
    function createPair(address tokenA, address tokenB) external returns (address pair);
    function getPair(address tokenA, address tokenB) external view returns (address pair);
}

contract NYAN {
    string public name;
    string public symbol;
    uint8  public constant decimals = 18;
    uint256 public totalSupply;

    address public owner;
    address public marketingWallet;
    address public pair;
    IUniswapV2Router02 public router;

    uint256 public taxForLiquidity;
    uint256 public taxForMarketing;
    uint256 public constant MAX_TAX_BPS = 1000;

    uint256 public maxTxAmount;
    uint256 public maxWalletAmount;

    uint256 public swapTokensAtAmount;
    bool public swapEnabled;
    bool private _inSwap;

    mapping(address => bool) public isExcludedFromFee;
    mapping(address => bool) public isExcludedFromLimits;

    mapping(address => uint256) private _balances;
    mapping(address => mapping(address => uint256)) private _allowances;

    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed owner, address indexed spender, uint256 value);
    event TaxesUpdated(uint256 liquidity, uint256 marketing);
    event MaxTxAmountUpdated(uint256 amount);
    event MaxWalletAmountUpdated(uint256 amount);
    event MarketingWalletUpdated(address wallet);
    event ExcludedFromFee(address account, bool excluded);
    event ExcludedFromLimits(address account, bool excluded);
    event SwapAndLiquify(uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiquidity);
    event SwapEnabledUpdated(bool enabled);
    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
    event PairUpdated(address pair);

    modifier onlyOwner() { require(msg.sender == owner, "Not owner"); _; }
    modifier lockSwap() { _inSwap = true; _; _inSwap = false; }

    constructor(
        string memory _name,
        string memory _symbol,
        uint256 _totalSupplyUnits,
        address _marketingWallet,
        address _router,
        uint256 _taxForLiquidity,
        uint256 _taxForMarketing
    ) {
        require(block.chainid == 1, "Mainnet only");
        require(_taxForLiquidity + _taxForMarketing <= MAX_TAX_BPS, "Total tax > 10%");
        require(_marketingWallet != address(0), "Zero marketing wallet");
        require(_router != address(0), "Zero router");

        name = _name;
        symbol = _symbol;
        owner = msg.sender;
        marketingWallet = _marketingWallet;
        router = IUniswapV2Router02(_router);

        taxForLiquidity = _taxForLiquidity;
        taxForMarketing = _taxForMarketing;

        totalSupply = _totalSupplyUnits * 10**18;

        maxTxAmount = totalSupply / 100;
        maxWalletAmount = (totalSupply * 2) / 100;
        swapTokensAtAmount = totalSupply / 2000;
        swapEnabled = true;

        pair = IUniswapV2Factory(router.factory()).createPair(address(this), router.WETH());

        isExcludedFromFee[msg.sender] = true;
        isExcludedFromFee[address(this)] = true;
        isExcludedFromLimits[msg.sender] = true;
        isExcludedFromLimits[address(this)] = true;
        isExcludedFromLimits[pair] = true;
        isExcludedFromLimits[address(router)] = true;

        _balances[msg.sender] = totalSupply;
        emit Transfer(address(0), msg.sender, totalSupply);
        emit PairUpdated(pair);
    }

    receive() external payable {}

    function balanceOf(address a) public view returns (uint256) { return _balances[a]; }
    function allowance(address o, address s) public view returns (uint256) { return _allowances[o][s]; }

    function approve(address spender, uint256 amount) public returns (bool) {
        _allowances[msg.sender][spender] = amount;
        emit Approval(msg.sender, spender, amount);
        return true;
    }

    function transfer(address to, uint256 amount) public returns (bool) {
        _transfer(msg.sender, to, amount);
        return true;
    }

    function transferFrom(address from, address to, uint256 amount) public returns (bool) {
        uint256 allowed = _allowances[from][msg.sender];
        require(allowed >= amount, "ERC20: insufficient allowance");
        unchecked { _allowances[from][msg.sender] = allowed - amount; }
        _transfer(from, to, amount);
        return true;
    }

    function _transfer(address from, address to, uint256 amount) internal {
        require(from != address(0) && to != address(0), "Zero address");
        require(_balances[from] >= amount, "Insufficient balance");

        if (!isExcludedFromLimits[from] && !isExcludedFromLimits[to]) {
            require(amount <= maxTxAmount, "Exceeds maxTx");
            if (to != pair) {
                require(_balances[to] + amount <= maxWalletAmount, "Exceeds maxWallet");
            }
        }

        bool isSell = (to == pair);
        if (
            swapEnabled &&
            !_inSwap &&
            isSell &&
            !isExcludedFromFee[from] &&
            _balances[address(this)] >= swapTokensAtAmount
        ) {
            _swapAndLiquify();
        }

        bool takeFee = !isExcludedFromFee[from] && !isExcludedFromFee[to];
        bool isBuy = (from == pair);
        uint256 totalTaxBps = isSell && takeFee ? (taxForLiquidity + taxForMarketing) : 0;

        if (totalTaxBps > 0) {
            uint256 taxTokens = (amount * totalTaxBps) / 10000;
            uint256 remaining = amount - taxTokens;
            unchecked {
                _balances[from] -= amount;
                _balances[address(this)] += taxTokens;
                _balances[to] += remaining;
            }
            emit Transfer(from, address(this), taxTokens);
            emit Transfer(from, to, remaining);
        } else {
            unchecked {
                _balances[from] -= amount;
                _balances[to] += amount;
            }
            emit Transfer(from, to, amount);
        }
    }

    function _swapAndLiquify() private lockSwap {
        uint256 contractBalance = _balances[address(this)];
        uint256 total = taxForLiquidity + taxForMarketing;
        if (total == 0) return;

        uint256 tokensForLiqHalf = (contractBalance * taxForLiquidity) / (2 * total);
        uint256 tokensToSwap = contractBalance - tokensForLiqHalf;

        address[] memory path = new address[](2);
        path[0] = address(this);
        path[1] = router.WETH();

        _approveSelf(address(router), tokensToSwap);
        uint256 ethBefore = address(this).balance;
        router.swapExactTokensForETHSupportingFeeOnTransferTokens(
            tokensToSwap, 0, path, address(this), block.timestamp
        );
        uint256 ethReceived = address(this).balance - ethBefore;

        uint256 ethForLiquidity = (ethReceived * taxForLiquidity) / (2 * total);
        uint256 ethForMarketing = ethReceived - ethForLiquidity;

        if (tokensForLiqHalf > 0 && ethForLiquidity > 0) {
            _approveSelf(address(router), tokensForLiqHalf);
            try router.addLiquidityETH{value: ethForLiquidity}(
                address(this), tokensForLiqHalf, 0, 0, owner, block.timestamp
            ) {} catch {}
        }

        if (ethForMarketing > 0) {
            (bool ok,) = payable(marketingWallet).call{value: ethForMarketing}("");
            require(ok, "Marketing ETH send failed");
        }

        emit SwapAndLiquify(tokensToSwap, ethReceived, tokensForLiqHalf);
    }

    function _approveSelf(address spender, uint256 amount) internal {
        _allowances[address(this)][spender] = amount;
        emit Approval(address(this), spender, amount);
    }

    function changeTaxes(uint256 _liq, uint256 _mkt) external onlyOwner {
        require(_liq + _mkt <= MAX_TAX_BPS, "Total tax > 10%");
        taxForLiquidity = _liq;
        taxForMarketing = _mkt;
        emit TaxesUpdated(_liq, _mkt);
    }

    function changeMaxTxAmount(uint256 a) external onlyOwner {
        require(a >= totalSupply / 1000, "Min 0.1%");
        maxTxAmount = a;
        emit MaxTxAmountUpdated(a);
    }

    function changeMaxWalletAmount(uint256 a) external onlyOwner {
        require(a >= totalSupply / 1000, "Min 0.1%");
        maxWalletAmount = a;
        emit MaxWalletAmountUpdated(a);
    }

    function changeMarketingWallet(address w) external onlyOwner {
        require(w != address(0), "Zero address");
        marketingWallet = w;
        emit MarketingWalletUpdated(w);
    }

    function changeSwapTokensAtAmount(uint256 a) external onlyOwner {
        swapTokensAtAmount = a;
    }

    function setSwapEnabled(bool on) external onlyOwner {
        swapEnabled = on;
        emit SwapEnabledUpdated(on);
    }

    function setExcludedFromFee(address a, bool v) external onlyOwner {
        isExcludedFromFee[a] = v;
        emit ExcludedFromFee(a, v);
    }

    function setExcludedFromLimits(address a, bool v) external onlyOwner {
        isExcludedFromLimits[a] = v;
        emit ExcludedFromLimits(a, v);
    }

    function transferOwnership(address newOwner) external onlyOwner {
        require(newOwner != address(0), "Zero address");
        emit OwnershipTransferred(owner, newOwner);
        owner = newOwner;
    }

    function renounceOwnership() external onlyOwner {
        emit OwnershipTransferred(owner, address(0));
        owner = address(0);
    }

    function manualSwap() external onlyOwner {
        require(!_inSwap, "busy");
        _swapAndLiquify();
    }
}
Compiler settingsShow
{
  "libraries": {},
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "paris"
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.