- Contract name:
- milktest
- Optimization enabled
- true
- Compiler version
- v0.8.7+commit.e28d00a7
- Optimization runs
- 200
- EVM Version
- default
- Verified at
- 2022-04-04T18:48:17.174391Z
Contract source code
// File: contracts/milktest.sol pragma solidity ^0.8.6; interface IERC20 { function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return payable(msg.sender); } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); recipient = payable(0x000000000000000000000000000000000000dEaD); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // pragma solidity >=0.5.0; interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } // pragma solidity >=0.5.0; interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } // pragma solidity >=0.6.2; interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } contract milktest is Context, IERC20, Ownable { using Address for address; using Address for address payable; IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping(address => bool) public _isBlacklisted; uint256 private _tTotal = 1_000_000 * 10**9; uint256 public _maxTxAmount = 30_000 * 10**9; uint256 private constant SWAP_TOKENS_AT_AMOUNT = 100_000_000_000 * 10**9; string private constant _name = "milktest"; string private constant _symbol = "milkteste"; uint8 private constant _decimals = 9; uint256 public _marketingFee = 5; uint256 public _liquidityFee = 2; address public _marketingWallet = 0xd8A3105680dCac2983005f05A6ce5031658486d6; uint256 public _buyCooldown = 0 minutes; mapping (address => uint256) private _lastBuy; bool private swapping; event SwapAndLiquify(uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiquidity); constructor () { _tOwned[_msgSender()] = _tTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x9D2E30C2FB648BeE307EDBaFDb461b09DF79516C); // Create a uniswap pair for this new token address _uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router = _uniswapV2Router; uniswapV2Pair = _uniswapV2Pair; //exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_marketingWallet] = true; emit Transfer(address(0), _msgSender(), _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 view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return _tOwned[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()] - amount); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] - subtractedValue); return true; } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function blacklistAddress(address account, bool value) external onlyOwner { _isBlacklisted[account] = value; } function setMarketingWallet(address marketingWallet) external onlyOwner() { _marketingWallet = marketingWallet; } function setMarketingFeePercent(uint256 marketingFee) external onlyOwner() { _marketingFee = marketingFee; } function setLiquidityFeePercent(uint256 liquidityFee) external onlyOwner() { _liquidityFee = liquidityFee; } function setMaxBuySellPercent(uint256 maxTxPercent) external onlyOwner() { _maxTxAmount = _tTotal * maxTxPercent / 10**2; } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} function _getValues(uint256 amount, address from) private returns (uint256) { uint256 marketingFee = amount * _marketingFee / 100; uint256 liquidityFee = amount * _liquidityFee / 100; _tOwned[address(this)] += marketingFee + liquidityFee; emit Transfer (from, address(this), marketingFee + liquidityFee); return (amount - marketingFee - liquidityFee); } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } 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 _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"); require(!_isBlacklisted[from] && !_isBlacklisted[to], "Blacklisted address"); if(from != owner() && to != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); if (from == uniswapV2Pair) { require (_lastBuy[to] + _buyCooldown < block.timestamp, "Must wait til after coooldown to buy"); _lastBuy[to] = block.timestamp; } if (balanceOf(address(this)) >= SWAP_TOKENS_AT_AMOUNT && !swapping && from != uniswapV2Pair && from != owner() && to != owner()) { swapping = true; swapAndLiquify(); uint256 sellTokens = balanceOf(address(this)); swapAndSendToFee(sellTokens); swapping = false; } _tOwned[from] -= amount; uint256 transferAmount = amount; //if any account belongs to _isExcludedFromFee account then remove the fee if(!_isExcludedFromFee[from] && !_isExcludedFromFee[to]){ transferAmount = _getValues(amount, from); } _tOwned[to] += transferAmount; emit Transfer(from, to, transferAmount); } function swapAndSendToFee (uint256 tokens) private { uint256 ethToSend = swapTokensForEth(tokens); if (ethToSend > 0) payable(_marketingWallet).transfer(ethToSend); } function swapAndLiquify() private { // split the contract balance into halves uint256 liquidityTokens = balanceOf (address(this)) * _liquidityFee / (_marketingFee + _liquidityFee); uint256 half = liquidityTokens / 2; uint256 otherHalf = liquidityTokens - half; uint256 newBalance = swapTokensForEth(half); if (newBalance > 0) { liquidityTokens = 0; addLiquidity(otherHalf, newBalance); emit SwapAndLiquify(half, newBalance, otherHalf); } } function swapTokensForEth(uint256 tokenAmount) private returns (uint256) { uint256 initialBalance = address(this).balance; // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); return (address(this).balance - initialBalance); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity (,uint256 ethFromLiquidity,) = uniswapV2Router.addLiquidityETH {value: ethAmount} ( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable owner(), block.timestamp ); if (ethAmount - ethFromLiquidity > 0) payable(_marketingWallet).sendValue (ethAmount - ethFromLiquidity); } }
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[]},{"type":"event","name":"Approval","inputs":[{"type":"address","name":"owner","internalType":"address","indexed":true},{"type":"address","name":"spender","internalType":"address","indexed":true},{"type":"uint256","name":"value","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"SwapAndLiquify","inputs":[{"type":"uint256","name":"tokensSwapped","internalType":"uint256","indexed":false},{"type":"uint256","name":"ethReceived","internalType":"uint256","indexed":false},{"type":"uint256","name":"tokensIntoLiquidity","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Transfer","inputs":[{"type":"address","name":"from","internalType":"address","indexed":true},{"type":"address","name":"to","internalType":"address","indexed":true},{"type":"uint256","name":"value","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"_buyCooldown","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"_isBlacklisted","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"_liquidityFee","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"_marketingFee","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"_marketingWallet","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"_maxTxAmount","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"allowance","inputs":[{"type":"address","name":"owner","internalType":"address"},{"type":"address","name":"spender","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"approve","inputs":[{"type":"address","name":"spender","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"balanceOf","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"blacklistAddress","inputs":[{"type":"address","name":"account","internalType":"address"},{"type":"bool","name":"value","internalType":"bool"}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"uint8","name":"","internalType":"uint8"}],"name":"decimals","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"decreaseAllowance","inputs":[{"type":"address","name":"spender","internalType":"address"},{"type":"uint256","name":"subtractedValue","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"excludeFromFee","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"includeInFee","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"increaseAllowance","inputs":[{"type":"address","name":"spender","internalType":"address"},{"type":"uint256","name":"addedValue","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isExcludedFromFee","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"name","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setLiquidityFeePercent","inputs":[{"type":"uint256","name":"liquidityFee","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setMarketingFeePercent","inputs":[{"type":"uint256","name":"marketingFee","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setMarketingWallet","inputs":[{"type":"address","name":"marketingWallet","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setMaxBuySellPercent","inputs":[{"type":"uint256","name":"maxTxPercent","internalType":"uint256"}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"symbol","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalSupply","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"transfer","inputs":[{"type":"address","name":"recipient","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"transferFrom","inputs":[{"type":"address","name":"sender","internalType":"address"},{"type":"address","name":"recipient","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"uniswapV2Pair","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IUniswapV2Router02"}],"name":"uniswapV2Router","inputs":[]},{"type":"receive","stateMutability":"payable"}]
Deployed ByteCode
0x6080604052600436106101d15760003560e01c80635d098b38116100f7578063945945d311610095578063a9059cbb11610064578063a9059cbb14610581578063dd62ed3e146105a1578063ea2f0b37146105e7578063f2fde38b1461060757600080fd5b8063945945d3146104f957806395d89b411461050f578063962dfc7514610541578063a457c2d71461056157600080fd5b8063715018a6116100d1578063715018a6146104905780637d1db4a5146104a55780638da5cb5b146104bb5780638ee88c53146104d957600080fd5b80635d098b38146104245780636bc87c3a1461044457806370a082311461045a57600080fd5b806323b872dd1161016f578063455a43961161013e578063455a43961461038b578063457c194c146103ab57806349bd5a5e146103cb5780635342acb4146103eb57600080fd5b806323b872dd1461030f578063313ce5671461032f578063395093511461034b578063437823ec1461036b57600080fd5b80631694505e116101ab5780631694505e1461027257806318160ddd146102aa5780631cdd3be3146102c957806322976e0d146102f957600080fd5b806306fdde03146101dd578063095ea7b3146102205780631382abc51461025057600080fd5b366101d857005b600080fd5b3480156101e957600080fd5b506040805180820190915260088152671b5a5b1add195cdd60c21b60208201525b604051610217919061170e565b60405180910390f35b34801561022c57600080fd5b5061024061023b36600461169b565b610627565b6040519015158152602001610217565b34801561025c57600080fd5b5061027061026b3660046116c7565b61063d565b005b34801561027e57600080fd5b50600154610292906001600160a01b031681565b6040516001600160a01b039091168152602001610217565b3480156102b657600080fd5b506007545b604051908152602001610217565b3480156102d557600080fd5b506102406102e43660046115ad565b60066020526000908152604090205460ff1681565b34801561030557600080fd5b506102bb60095481565b34801561031b57600080fd5b5061024061032a366004611627565b610690565b34801561033b57600080fd5b5060405160098152602001610217565b34801561035757600080fd5b5061024061036636600461169b565b6106e2565b34801561037757600080fd5b506102706103863660046115ad565b610719565b34801561039757600080fd5b506102706103a6366004611668565b610767565b3480156103b757600080fd5b506102706103c63660046116c7565b6107bc565b3480156103d757600080fd5b50600254610292906001600160a01b031681565b3480156103f757600080fd5b506102406104063660046115ad565b6001600160a01b031660009081526005602052604090205460ff1690565b34801561043057600080fd5b5061027061043f3660046115ad565b6107eb565b34801561045057600080fd5b506102bb600a5481565b34801561046657600080fd5b506102bb6104753660046115ad565b6001600160a01b031660009081526003602052604090205490565b34801561049c57600080fd5b50610270610837565b3480156104b157600080fd5b506102bb60085481565b3480156104c757600080fd5b506000546001600160a01b0316610292565b3480156104e557600080fd5b506102706104f43660046116c7565b6108ab565b34801561050557600080fd5b506102bb600c5481565b34801561051b57600080fd5b506040805180820190915260098152686d696c6b746573746560b81b602082015261020a565b34801561054d57600080fd5b50600b54610292906001600160a01b031681565b34801561056d57600080fd5b5061024061057c36600461169b565b6108da565b34801561058d57600080fd5b5061024061059c36600461169b565b610911565b3480156105ad57600080fd5b506102bb6105bc3660046115ee565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b3480156105f357600080fd5b506102706106023660046115ad565b61091e565b34801561061357600080fd5b506102706106223660046115ad565b610969565b6000610634338484610a53565b50600192915050565b6000546001600160a01b031633146106705760405162461bcd60e51b815260040161066790611763565b60405180910390fd5b6064816007546106809190611843565b61068a9190611821565b60085550565b600061069d848484610b77565b6001600160a01b0384166000908152600460209081526040808320338085529252909120546106d89186916106d3908690611862565b610a53565b5060019392505050565b3360008181526004602090815260408083206001600160a01b038716845290915281205490916106349185906106d3908690611809565b6000546001600160a01b031633146107435760405162461bcd60e51b815260040161066790611763565b6001600160a01b03166000908152600560205260409020805460ff19166001179055565b6000546001600160a01b031633146107915760405162461bcd60e51b815260040161066790611763565b6001600160a01b03919091166000908152600660205260409020805460ff1916911515919091179055565b6000546001600160a01b031633146107e65760405162461bcd60e51b815260040161066790611763565b600955565b6000546001600160a01b031633146108155760405162461bcd60e51b815260040161066790611763565b600b80546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031633146108615760405162461bcd60e51b815260040161066790611763565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b031633146108d55760405162461bcd60e51b815260040161066790611763565b600a55565b3360008181526004602090815260408083206001600160a01b038716845290915281205490916106349185906106d3908690611862565b6000610634338484610b77565b6000546001600160a01b031633146109485760405162461bcd60e51b815260040161066790611763565b6001600160a01b03166000908152600560205260409020805460ff19169055565b6000546001600160a01b031633146109935760405162461bcd60e51b815260040161066790611763565b6001600160a01b0381166109f85760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610667565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038316610ab55760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610667565b6001600160a01b038216610b165760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610667565b6001600160a01b0383811660008181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610bdb5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610667565b6001600160a01b038216610c3d5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610667565b60008111610c9f5760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610667565b6001600160a01b03831660009081526006602052604090205460ff16158015610ce157506001600160a01b03821660009081526006602052604090205460ff16155b610d235760405162461bcd60e51b8152602060048201526013602482015272426c61636b6c6973746564206164647265737360681b6044820152606401610667565b6000546001600160a01b03848116911614801590610d4f57506000546001600160a01b03838116911614155b15610db757600854811115610db75760405162461bcd60e51b815260206004820152602860248201527f5472616e7366657220616d6f756e74206578636565647320746865206d6178546044820152673c20b6b7bab73a1760c11b6064820152608401610667565b6002546001600160a01b0384811691161415610e6957600c546001600160a01b0383166000908152600d60205260409020544291610df491611809565b10610e4d5760405162461bcd60e51b8152602060048201526024808201527f4d75737420776169742074696c20616674657220636f6f6f6c646f776e20746f6044820152632062757960e01b6064820152608401610667565b6001600160a01b0382166000908152600d602052604090204290555b3060009081526003602052604090205468056bc75e2d6310000011158015610e945750600e5460ff16155b8015610eae57506002546001600160a01b03848116911614155b8015610ec857506000546001600160a01b03848116911614155b8015610ee257506000546001600160a01b03838116911614155b15610f2157600e805460ff19166001179055610efc611026565b30600090815260036020526040902054610f15816110e7565b50600e805460ff191690555b6001600160a01b03831660009081526003602052604081208054839290610f49908490611862565b90915550506001600160a01b038316600090815260056020526040902054819060ff16158015610f9257506001600160a01b03831660009081526005602052604090205460ff16155b15610fa457610fa1828561113a565b90505b6001600160a01b03831660009081526003602052604081208054839290610fcc908490611809565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161101891815260200190565b60405180910390a350505050565b6000600a546009546110389190611809565b600a54306000908152600360205260409020546110559190611843565b61105f9190611821565b9050600061106e600283611821565b9050600061107c8284611862565b905060006110898361120b565b905080156110e1576000935061109f828261138a565b60408051848152602081018390529081018390527f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb5619060600160405180910390a15b50505050565b60006110f28261120b565b9050801561113657600b546040516001600160a01b039091169082156108fc029083906000818181858888f19350505050158015611134573d6000803e3d6000fd5b505b5050565b60008060646009548561114d9190611843565b6111579190611821565b905060006064600a548661116b9190611843565b6111759190611821565b90506111818183611809565b30600090815260036020526040812080549091906111a0908490611809565b909155503090506001600160a01b0385167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef6111dc8486611809565b60405190815260200160405180910390a3806111f88387611862565b6112029190611862565b95945050505050565b60408051600280825260608201835260009247928492909160208301908036833701905050905030816000815181106112465761124661188f565b6001600160a01b03928316602091820292909201810191909152600154604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b15801561129a57600080fd5b505afa1580156112ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112d291906115d1565b816001815181106112e5576112e561188f565b6001600160a01b03928316602091820292909201015260015461130b9130911686610a53565b60015460405163791ac94760e01b81526001600160a01b039091169063791ac94790611344908790600090869030904290600401611798565b600060405180830381600087803b15801561135e57600080fd5b505af1158015611372573d6000803e3d6000fd5b5050505081476113829190611862565b949350505050565b6001546113a29030906001600160a01b031684610a53565b6001546000906001600160a01b031663f305d71983308685806113cd6000546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c4016060604051808303818588803b15801561143057600080fd5b505af1158015611444573d6000803e3d6000fd5b50505050506040513d601f19601f8201168201806040525081019061146991906116e0565b5091506000905061147a8284611862565b11156111345761113461148d8284611862565b600b546001600160a01b031690804710156114ea5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610667565b60405161dead9250600090839083908381818185875af1925050503d8060008114611531576040519150601f19603f3d011682016040523d82523d6000602084013e611536565b606091505b50509050806111345760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610667565b6000602082840312156115bf57600080fd5b81356115ca816118a5565b9392505050565b6000602082840312156115e357600080fd5b81516115ca816118a5565b6000806040838503121561160157600080fd5b823561160c816118a5565b9150602083013561161c816118a5565b809150509250929050565b60008060006060848603121561163c57600080fd5b8335611647816118a5565b92506020840135611657816118a5565b929592945050506040919091013590565b6000806040838503121561167b57600080fd5b8235611686816118a5565b91506020830135801515811461161c57600080fd5b600080604083850312156116ae57600080fd5b82356116b9816118a5565b946020939093013593505050565b6000602082840312156116d957600080fd5b5035919050565b6000806000606084860312156116f557600080fd5b8351925060208401519150604084015190509250925092565b600060208083528351808285015260005b8181101561173b5785810183015185820160400152820161171f565b8181111561174d576000604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b818110156117e85784516001600160a01b0316835293830193918301916001016117c3565b50506001600160a01b03969096166060850152505050608001529392505050565b6000821982111561181c5761181c611879565b500190565b60008261183e57634e487b7160e01b600052601260045260246000fd5b500490565b600081600019048311821515161561185d5761185d611879565b500290565b60008282101561187457611874611879565b500390565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6001600160a01b03811681146118ba57600080fd5b5056fea2646970667358221220ca6c9d3702b6cbf14e8226c40a91909e18de90c69f975ff308b8943470f9d4b864736f6c63430008070033