Skip to content
Verified contractPartialMIT

Ownable

Address0x3e1196277ea2550475b1eafe117783fbad70955c
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.8.34

 

Same code

485 more contracts

 

Details

Compiler
solc 0.8.34+commit.80d5c536
Language
solidity
Optimization
Yes, 200 runs
License
MIT
Match
Partialcreation code: no, runtime code: yes
Verified on Sourcify
Created in block
24,003,150
Creation transaction
0x60fc91c2fc…6190545346

novo3.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

interface IERC20 {
    function totalSupply() external view returns (uint256);
    function balanceOf(address account) external view returns (uint256);
    function transfer(address recipient, uint256 amount) external returns (bool);
    function allowance(address owner, address spender) external view returns (uint256);
    function approve(address spender, uint256 amount) external returns (bool);
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);

    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

abstract contract Context {
    function _msgSender() internal view returns (address) {
        return msg.sender;
    }
}

contract Ownable is Context {
    address public owner;

    constructor() {
        owner = msg.sender;
    }

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

interface IPancakeRouter {
    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;
}

interface IPancakeFactory {
    function createPair(address tokenA, address tokenB) external returns (address);
}

contract MorcegoToken is IERC20, Ownable {

    string public constant name = "Morcego";
    string public constant symbol = "MORC";
    uint8 public constant decimals = 18;

    uint256 private constant _totalSupply = 1_000_000_000 * 1e18;

    mapping(address => uint256) private balances;
    mapping(address => mapping(address => uint256)) private allowances;
    mapping(address => bool) public isExcludedFromFee;

    uint256 public buyFee = 5;
    uint256 public sellFee = 5;

    IPancakeRouter public router;
    address public pair;

    bool public tradingOpen = false;
    bool private swapping;

    uint256 public swapThreshold = _totalSupply / 10000;

    constructor(address routerAddress) {
        balances[msg.sender] = _totalSupply;

        router = IPancakeRouter(routerAddress);
        pair = IPancakeFactory(router.factory())
            .createPair(address(this), router.WETH());

        // 🔒 isenções importantes
        isExcludedFromFee[msg.sender] = true;
        isExcludedFromFee[address(this)] = true;
        isExcludedFromFee[address(router)] = true;
        isExcludedFromFee[pair] = true;

        emit Transfer(address(0), msg.sender, _totalSupply);
    }

    // 🔓 libera trading manualmente (importante para launch)
    function openTrading() external onlyOwner {
        tradingOpen = true;
    }

    receive() external payable {}

    function totalSupply() external pure override returns (uint256) {
        return _totalSupply;
    }

    function balanceOf(address account) public view override returns (uint256) {
        return balances[account];
    }

    function allowance(address owner_, address spender) public view override returns (uint256) {
        return allowances[owner_][spender];
    }

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

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

    function transferFrom(address from, address to, uint256 amount) public override returns (bool) {
        require(allowances[from][msg.sender] >= amount, "allowance low");

        allowances[from][msg.sender] -= amount;
        _transfer(from, to, amount);

        return true;
    }

    function _transfer(address from, address to, uint256 amount) internal {
        require(balances[from] >= amount, "balance low");

        uint256 fee = 0;

        // 🚫 bloqueia antes do launch
        if (!tradingOpen && from != owner) {
            revert("Trading not open");
        }

        // 🚫 sem taxa se isento
        if (!isExcludedFromFee[from] && !isExcludedFromFee[to]) {

            // compra
            if (from == pair) {
                fee = (amount * buyFee) / 100;
            }

            // venda
            if (to == pair) {
                fee = (amount * sellFee) / 100;
            }
        }

        balances[from] -= amount;

        uint256 received = amount - fee;
        balances[to] += received;

        if (fee > 0) {
            balances[address(this)] += fee;
            emit Transfer(from, address(this), fee);
        }

        emit Transfer(from, to, received);

        // 🔒 SWAP PROTEGIDO
        if (
            !swapping &&
            tradingOpen &&
            to == pair &&
            balances[address(this)] >= swapThreshold
        ) {
            swapForBNB();
        }
    }

    function swapForBNB() private {
        swapping = true;

        uint256 amount = balances[address(this)];

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

        allowances[address(this)][address(router)] = amount;

        router.swapExactTokensForETHSupportingFeeOnTransferTokens(
            amount,
            0,
            path,
            owner,
            block.timestamp
        );

        swapping = false;
    }
}
Compiler settingsShow
{
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "remappings": []
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.