File size: 12,058 Bytes
f998fcd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
{
  "language": "Solidity",
  "sources": {
    "contracts/Hokkaido.sol": {
      "content": "//SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\n/// @title IERC20 Token Standard\n/// @notice Interface for the ERC20 standard token contract\ninterface IERC20 {\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    event Approval(\n        address indexed owner,\n        address indexed spender,\n        uint256 value\n    );\n\n    function totalSupply() external view returns (uint256);\n\n    function balanceOf(address account) external view returns (uint256);\n\n    function transfer(address to, uint256 amount) external returns (bool);\n\n    function allowance(address owner, address spender)\n        external\n        view\n        returns (uint256);\n\n    function approve(address spender, uint256 amount) external returns (bool);\n\n    function transferFrom(\n        address from,\n        address to,\n        uint256 amount\n    ) external returns (bool);\n}\n\n/// @title Interface for UniswapV2Factory Contract\n/// @notice It is used to create new instances of pairs\ninterface IUniswapV2Factory {\n    function createPair(address tokenA, address tokenB)\n        external\n        returns (address pair);\n}\n\n/// @title Interface for UniswapV2Router02 Contract\n/// @notice It is used to get information about liquidity reserves\ninterface IUniswapV2Router {\n    function factory() external pure returns (address);\n\n    function WETH() external pure returns (address);\n}\n\n/// @author Kenji Sato\n/// @title Hakkaido Token Contract\n/// @notice Hokkaido token is a utility token created for use on the Hokkaido platform,\n/// acting as an intermediary between the user's token and Uniswap pool.\n/// It implements the IERC20 token standard.\n/// @custom:website https://www.hokkaido.ai\n/// @custom:telegram https://t.me/hokk_token\n/// @custom:twitter https://twitter.com/hokk_token\ncontract Hokkaido is IERC20 {\n    // Address of the owner of the contract\n    address public owner;\n\n    // Total supply of the token\n    uint256 public totalSupply;\n\n    // Mapping of account addresses to their respective balances\n    mapping(address => uint256) public balances;\n    // Mapping of holder addresses to a mapping of spender addresses to their respective allowances\n    mapping(address => mapping(address => uint256)) public allowances;\n\n    // The timestamp when the time lock for purchasing tokens ends\n    // This is an anti-sniping bot measure to prevent purchases from the Uniswap during the specified time frame\n    uint256 public purchaseTimeLockEnd;\n\n    // The maximum number of tokens that a wallet can hold\n    // This is a measure to prevent price manipulation\n    // The maxWallet restriction will be removed after 24 hours from allowing trading\n    uint256 public maxWallet;\n\n    // The timestamp indicating the end time of the period during\n    // which a maximum wallet size is enforced\n    uint256 public maxWalletEndTime;\n\n    // The Uniswap V2 router contract\n    IUniswapV2Router public uniswapV2Router;\n    // The address of the Uniswap V2 liquidity pool for the token\n    address public uniswapV2Pair;\n\n    // Constants for token name, symbol and decimals\n    string private constant NAME = \"Hokkaido\";\n    string private constant SYMBOL = \"HOKK\";\n    uint8 private constant DECIMALS = 18;\n\n    // Event for transferring ownership of the contract\n    event OwnershipTransferred(\n        address indexed previousOwner,\n        address indexed newOwner\n    );\n\n    // Modifier to only allow the contract owner to execute a function\n    modifier onlyOwner() {\n        require(msg.sender == owner, \"Error: Caller is not the contract owner\");\n        _;\n    }\n\n    // Contract constructor\n    constructor(uint256 amount, uint256 timelock) {\n        // Create a new instance of IUniswapV2Router\n        IUniswapV2Router _uniswapV2Router = IUniswapV2Router(\n            0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\n        );\n        // Assign the new instance to the uniswapV2Router variable\n        uniswapV2Router = _uniswapV2Router;\n        // Create a new Uniswap pair for this new token\n        uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())\n            .createPair(address(this), _uniswapV2Router.WETH());\n        // Assign the time lock for purchasing tokens\n        purchaseTimeLockEnd = timelock;\n\n        // Assign the end time of the period during which a maximum wallet size is enforced\n        maxWalletEndTime = purchaseTimeLockEnd + 24 hours;\n\n        // Assign the totalSupply to the given amount\n        totalSupply = amount;\n        // Assign the maxWallet to 2% of the totalSupply\n        maxWallet = (totalSupply * 2) / 100;\n        // Assign the full amount to the balance of the contract creator\n        balances[msg.sender] = totalSupply;\n\n        // Emit a Transfer event from address 0 to the contract creator with the totalSupply as the value\n        emit Transfer(address(0), msg.sender, totalSupply);\n        // Set the owner to the contract creator\n        owner = msg.sender;\n    }\n\n    /**\n     * @dev Returns the balance of the specified address.\n     * @param account The address to retrieve the balance of.\n     * @return The balance of the specified address.\n     */\n    function balanceOf(address account)\n        external\n        view\n        override\n        returns (uint256)\n    {\n        return balances[account];\n    }\n\n    /**\n     * @dev Returns the allowance of a spender for a given holder.\n     * @param holder The address of the holder.\n     * @param spender The address of the spender.\n     * @return The allowance of the spender for the given holder.\n     */\n    function allowance(address holder, address spender)\n        external\n        view\n        override\n        returns (uint256)\n    {\n        return allowances[holder][spender];\n    }\n\n    /**\n     * @dev Returns the name of the token.\n     * @return string memory The name of the token.\n     */\n    function name() external pure returns (string memory) {\n        return NAME;\n    }\n\n    /**\n     * @dev Returns the symbol of the token.\n     * @return string memory The symbol of the token.\n     */\n    function symbol() external pure returns (string memory) {\n        return SYMBOL;\n    }\n\n    /**\n     * @dev Returns the number of decimal places used to represent the token amount.\n     * @return uint8 The number of decimal places used to represent the token amount.\n     */\n    function decimals() external pure returns (uint8) {\n        return DECIMALS;\n    }\n\n    /**\n     * @dev Approves the given spender to transfer the specified amount from the msg.sender's account.\n     * @param spender The address of the spender to approve.\n     * @param amount The amount of token to be approved for transfer.\n     * @return bool True if the approval was successful.\n     */\n    function approve(address spender, uint256 amount)\n        external\n        virtual\n        override\n        returns (bool)\n    {\n        allowances[msg.sender][spender] = amount;\n        emit Approval(msg.sender, spender, amount);\n        return true;\n    }\n\n    /**\n     * @dev Renounces ownership of the contract.\n     */\n    function renounceOwnership() external virtual onlyOwner {\n        _transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers the specified amount of tokens from the sender to the recipient on behalf of the sender.\n     * @param sender The address of the token holder to transfer from.\n     * @param recipient The address of the recipient to transfer to.\n     * @param amount The amount of token to be transferred.\n     * @return bool True if the transfer was successful.\n     */\n    function transferFrom(\n        address sender,\n        address recipient,\n        uint256 amount\n    ) external override returns (bool) {\n        // Check if the allowance is sufficient\n        require(\n            allowances[sender][msg.sender] >= amount,\n            \"Error: insufficient allowance.\"\n        );\n\n        // Decrease the allowance\n        allowances[sender][msg.sender] -= amount;\n\n        return _transfer(sender, recipient, amount);\n    }\n\n    /**\n     * @dev Transfers the specified amount of tokens from the msg.sender's account to the recipient.\n     * @param recipient The address of the recipient to transfer to.\n     * @param amount The amount of token to be transferred.\n     * @return bool True if the transfer was successful.\n     */\n    function transfer(address recipient, uint256 amount)\n        external\n        override\n        returns (bool)\n    {\n        return _transfer(msg.sender, recipient, amount);\n    }\n\n    /**\n     * @dev Transfers the ownership of the contract to the new owner.\n     * @param newOwner The address of the new owner.\n     */\n    function _transferOwnership(address newOwner) internal virtual {\n        address oldOwner = owner;\n        owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n\n    /**\n     * @dev Transfers `amount` tokens from `sender` to `recipient`.\n     *\n     * @param sender The address of the sender.\n     * @param recipient The address of the recipient.\n     * @param amount The amount of tokens to transfer.\n     *\n     * @return A boolean indicating whether the transfer was successful.\n     */\n    function _transfer(\n        address sender,\n        address recipient,\n        uint256 amount\n    ) internal virtual returns (bool) {\n        // Ensure that the `sender` and `recipient` addresses are not the zero address\n        require(\n            sender != address(0) && recipient != address(0),\n            \"Error: Transfer from/to the zero address is not allowed.\"\n        );\n\n        // Check the balance of the `sender` to make sure the transfer amount is valid\n        uint256 senderBalance = balances[sender];\n        require(\n            senderBalance >= amount,\n            \"Error: Transfer amount exceeds the sender's balance.\"\n        );\n\n        // Prevent purchases from the Uniswap during a specified time lock period\n        // which serves as an anti-sniping bot measure.\n        if (sender == uniswapV2Pair && block.timestamp < purchaseTimeLockEnd) {\n            revert(\n                \"Error: Purchase from Uniswap DEX not allowed during timelock period.\"\n            );\n        }\n\n        // Check whether the maxWallet restriction is in effect\n        // and the recipient is not the UniswapV2 pair since we need to add liquidity\n        if (block.timestamp < maxWalletEndTime && recipient != uniswapV2Pair) {\n            // Check whether the sum of the recipient's current balance\n            // and the transferred amount exceeds the maxWallet limit\n            require(\n                balances[recipient] + amount <= maxWallet,\n                \"Error: Recipient balance exceeds maximum wallet size.\"\n            );\n        } else if (\n            block.timestamp >= maxWalletEndTime && maxWalletEndTime != 0\n        ) {\n            // Remove the maxWallet restriction after the specified time lock period\n            maxWallet = totalSupply;\n            maxWalletEndTime = 0;\n        }\n\n        // Perform the transfer\n        balances[sender] -= amount;\n        balances[recipient] += amount;\n\n        // Emit the Transfer event\n        emit Transfer(sender, recipient, amount);\n\n        // Return true to indicate the transfer was successful\n        return true;\n    }\n}\n"
    }
  },
  "settings": {
    "optimizer": {
      "enabled": true,
      "runs": 200
    },
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "devdoc",
          "userdoc",
          "metadata",
          "abi"
        ]
      }
    },
    "libraries": {}
  }
}