Verified contractExactMIT
SlerfTools_TaxToken
Address0x9a19fc07b2ef2c2eed0c507af15a68efe528a635
- Balance
0 ETH
- Transactions
9
- Compiler
solc 0.8.38
- Same code
1 more contract
Details
- Compiler
- solc 0.8.38+commit.1835d247
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- paris
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,413,806
- Creation transaction
- 0x57ae3619d7…1167316001
SlerfTools_TaxToken.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/*
$$$$$$\ $$\ $$$$$$\ $$$$$$$$\ $$\
$$ __$$\ $$ | $$ __$$\ \__$$ __| $$ |
$$ / \__|$$ | $$$$$$\ $$$$$$\ $$ / \__| $$ | $$$$$$\ $$$$$$\ $$ | $$$$$$$\
\$$$$$$\ $$ |$$ __$$\ $$ __$$\ $$$$\ $$ |$$ __$$\ $$ __$$\ $$ |$$ _____|
\____$$\ $$ |$$$$$$$$ |$$ | \__|$$ _| $$ |$$ / $$ |$$ / $$ |$$ |\$$$$$$\
$$\ $$ |$$ |$$ ____|$$ | $$ | $$ |$$ | $$ |$$ | $$ |$$ | \____$$\
\$$$$$$ |$$ |\$$$$$$$\ $$ | $$ | $$ |\$$$$$$ |\$$$$$$ |$$ |$$$$$$$ |
\______/ \__| \_______|\__| \__| \__| \______/ \______/ \__|\_______/
*/
// @author Slerf Tools
/**
* @title Base Context Contract
* @dev Provides basic context functionality
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
/**
* @title ERC20 Interface
* @dev Standard ERC20 token interface
*/
interface IERC20 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, 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 from, address to, uint256 amount) external returns (bool);
}
/**
* @title Ownership Management Contract
* @dev Provides basic ownership management functionality
*/
abstract contract Ownable is Context {
// State variables
address private _owner;
bool private _ownershipRenounced;
address public constant BLACK_HOLE = 0x000000000000000000000000000000000000dEaD;
// Events
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
event OwnershipRenouncedToBlackHole(address indexed previousOwner, uint256 timestamp);
/**
* @dev Constructor
* @param initialOwner Initial owner address
*/
constructor(address initialOwner) {
require(initialOwner != address(0), "Ownable: zero address not allowed for initial owner");
_transferOwnership(initialOwner);
}
/**
* @dev Modifier that requires the caller to be the owner
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns current owner
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Checks if caller is owner
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Renounces ownership
*/
function renounceOwnership() public virtual onlyOwner {
require(!_ownershipRenounced, "Ownable: ownership already renounced");
_ownershipRenounced = true;
emit OwnershipRenouncedToBlackHole(owner(), block.timestamp);
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: zero address not allowed for new owner");
_transferOwnership(newOwner);
}
/**
* @dev Internal ownership transfer
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
/**
* @dev Checks if ownership is renounced
*/
function isOwnershipRenounced() public view virtual returns (bool) {
return _ownershipRenounced || owner() == address(0) || owner() == BLACK_HOLE;
}
}
/**
* @title ERC20 Base Implementation
* @dev Implements basic functionality of ERC20 interface
*/
abstract contract ERC20 is Context, IERC20 {
// State variables
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Constructor
*/
constructor(string memory name_, string memory symbol_, uint8 decimals_) {
_name = name_;
_symbol = symbol_;
_decimals = decimals_;
}
// Base query functions
function name() public view virtual returns (string memory) {
return _name;
}
function symbol() public view virtual returns (string memory) {
return _symbol;
}
function decimals() public view virtual returns (uint8) {
return _decimals;
}
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
// Transfer related functions
function transfer(address to, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_transfer(owner, to, amount);
return true;
}
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
// If current allowance is not 0 and new value is not 0, reset to 0 first (prevents front-running attack)
if (_allowances[owner][spender] != 0 && amount != 0) {
_approve(owner, spender, 0);
}
_approve(owner, spender, amount);
return true;
}
function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, amount);
return true;
}
// Authorization related functions
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
address owner = _msgSender();
uint256 currentAllowance = allowance(owner, spender);
// Explicitly check overflow (although Solidity 0.8+ checks automatically, explicit check is clearer)
require(
currentAllowance <= type(uint256).max - addedValue,
"ERC20: allowance overflow"
);
_approve(owner, spender, currentAllowance + addedValue);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
address owner = _msgSender();
uint256 currentAllowance = allowance(owner, spender);
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
return true;
}
// Internal functions
function _transfer(address from, address to, uint256 amount) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
_balances[to] += amount;
}
emit Transfer(from, to, amount);
}
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply += amount;
unchecked {
_balances[account] += amount;
}
emit Transfer(address(0), account, amount);
}
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
}
emit Transfer(account, address(0), amount);
}
function _approve(address owner, address spender, uint256 amount) internal virtual {
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 _spendAllowance(address owner, address spender, uint256 amount) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - amount);
}
}
}
}
/**
* @title Uniswap V2 Factory Interface
*/
interface IUniswapV2Factory {
function createPair(address tokenA, address tokenB) external returns (address pair);
}
/**
* @title Uniswap V2 Router Interface
*/
interface IUniswapV2Router02 {
function factory() external pure returns (address);
function WETH() external pure returns (address);
}
/**
* @title Tax Fee Token Contract
* @dev Implements ERC20 token with transaction fee functionality
*/
contract SlerfTools_TaxToken is ERC20, Ownable {
// Constants
uint256 public constant MAX_TAX = 2500; // 25%
string public constant TOKEN_TYPE = "TAX";
bytes32 public constant TOKEN_TYPE_HASH = keccak256(bytes(TOKEN_TYPE));
string public constant TOKEN_VERSION = "v1";
bytes32 public constant TOKEN_VERSION_HASH = keccak256(bytes(TOKEN_VERSION));
// State variables
uint256 public buyTax; // Buy tax (basis points, 100 = 1%)
uint256 public sellTax; // Sell tax (basis points, 100 = 1%)
address public taxReceiver; // Tax receiver address
bool public tradingEnabled; // Trading status
// Uniswap related
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
// Mappings
mapping(address => bool) public isExcludedFromFees;
mapping(address => bool) public automatedMarketMakerPairs;
// Events
event TradingEnabled();
event TradingDisabled();
event TaxUpdated(uint256 buyTax, uint256 sellTax);
event TaxReceiverUpdated(address newReceiver);
event ExcludeFromFees(address indexed account, bool isExcluded);
event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value);
function tokenType() external pure returns (string memory) {
return TOKEN_TYPE;
}
function tokenTypeHash() external pure returns (bytes32) {
return TOKEN_TYPE_HASH;
}
function tokenVersion() external pure returns (string memory) {
return TOKEN_VERSION;
}
function tokenVersionHash() external pure returns (bytes32) {
return TOKEN_VERSION_HASH;
}
/**
* @dev Constructor
*/
constructor(
string memory name_,
string memory symbol_,
uint8 decimals_,
uint256 totalSupply_,
uint256 buyTax_,
uint256 sellTax_,
address taxReceiver_,
address router_,
address owner_,
address pairedToken_,
address tokenReceiver_
) ERC20(name_, symbol_, decimals_) Ownable(owner_) {
require(buyTax_ <= MAX_TAX && sellTax_ <= MAX_TAX, "Tax rate exceeds maximum limit");
require(taxReceiver_ != address(0) && router_ != address(0), "Zero address not allowed");
require(tokenReceiver_ != address(0), "Zero address not allowed for token receiver");
buyTax = buyTax_;
sellTax = sellTax_;
taxReceiver = taxReceiver_;
uniswapV2Router = IUniswapV2Router02(router_);
// Create trading pair
address _uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(
address(this),
pairedToken_ == address(0) ? uniswapV2Router.WETH() : pairedToken_
);
uniswapV2Pair = _uniswapV2Pair;
// Set AMM pair
_setAutomatedMarketMakerPair(_uniswapV2Pair, true);
// Set fee exclusions
_excludeFromFees(address(this), true);
_excludeFromFees(address(uniswapV2Router), true);
// Limit decimals to reasonable range (typically <= 18)
require(decimals_ <= 18, "Decimals too large");
require(totalSupply_ > 0, "Initial supply must be greater than 0");
// Calculate total supply, check for overflow
uint256 multiplier = 10 ** uint256(decimals_);
require(
totalSupply_ <= type(uint256).max / multiplier,
"Total supply overflow"
);
uint256 totalAmount = totalSupply_ * multiplier;
_mint(tokenReceiver_, totalAmount);
}
/**
* @dev Transfer implementation
*/
function _transfer(
address from,
address to,
uint256 amount
) internal virtual override {
require(from != address(0) && to != address(0), "Zero address not allowed");
require(tradingEnabled || isExcludedFromFees[from] || isExcludedFromFees[to], "Trading not enabled");
if (amount == 0) {
super._transfer(from, to, 0);
return;
}
// Calculate fees
uint256 fees = 0;
if (!isExcludedFromFees[from] && !isExcludedFromFees[to]) {
if (automatedMarketMakerPairs[from] && buyTax > 0) {
fees = amount * buyTax / 10000;
} else if (automatedMarketMakerPairs[to] && sellTax > 0) {
fees = amount * sellTax / 10000;
}
}
// Transfer fees
if (fees > 0) {
super._transfer(from, taxReceiver, fees);
amount -= fees;
}
super._transfer(from, to, amount);
}
// Management functions
function enableTrading() external onlyOwner {
require(!tradingEnabled, "Trading already enabled");
tradingEnabled = true;
emit TradingEnabled();
}
function disableTrading() external onlyOwner {
require(tradingEnabled, "Trading already disabled");
tradingEnabled = false;
emit TradingDisabled();
}
function updateTax(uint256 buyTax_, uint256 sellTax_) external onlyOwner {
require(buyTax_ <= MAX_TAX && sellTax_ <= MAX_TAX, "Tax rate exceeds maximum limit");
buyTax = buyTax_;
sellTax = sellTax_;
emit TaxUpdated(buyTax_, sellTax_);
}
function updateTaxReceiver(address newReceiver) external onlyOwner {
require(newReceiver != address(0), "Zero address not allowed");
taxReceiver = newReceiver;
emit TaxReceiverUpdated(newReceiver);
}
function excludeFromFees(address account, bool excluded) external onlyOwner {
_excludeFromFees(account, excluded);
}
function _excludeFromFees(address account, bool excluded) internal {
isExcludedFromFees[account] = excluded;
emit ExcludeFromFees(account, excluded);
}
function setAutomatedMarketMakerPair(address pair, bool value) external onlyOwner {
require(pair != uniswapV2Pair, "Cannot remove main pair");
_setAutomatedMarketMakerPair(pair, value);
}
function _setAutomatedMarketMakerPair(address pair, bool value) private {
automatedMarketMakerPairs[pair] = value;
emit SetAutomatedMarketMakerPair(pair, value);
}
// Emergency rescue
function rescueTokens(address tokenAddress, uint256 amount) external onlyOwner {
IERC20(tokenAddress).transfer(owner(), amount);
}
receive() external payable {}
}
Compiler settingsShow
{
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "paris"
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.