文件 1 的 1:Evire.sol
pragma solidity 0.8.20;
interface IERC20 {
event Transfer(address indexed sender, address indexed recipient, uint256 amount);
event Approval(address indexed owner, address indexed spender, uint256 amount);
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);
}
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
}
contract Ownable is Context {
address private _contractOwner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() {
address msgSender = _msgSender();
_contractOwner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
function owner() public view returns (address) {
return _contractOwner;
}
modifier onlyOwner() {
require(_contractOwner == _msgSender(), "Ownable: caller is not the owner");
_;
}
function transferOwnership(address newOwner) public onlyOwner {
_updateOwnership(newOwner);
}
function _updateOwnership(address newOwner) internal {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_contractOwner, newOwner);
_contractOwner = newOwner;
}
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_contractOwner, address(0));
_contractOwner = address(0);
}
}
interface IUniswapV2Factory {
function createPair(address tokenA, address tokenB) external returns (address pair);
}
interface IUniswapV2Router02 {
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint256 tokenAmount,
uint256 minETHAmount,
address[] calldata path,
address to,
uint256 deadline
) external;
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidityETH(
address token,
uint tokenDesired,
uint tokenMin,
uint ethMin,
address to,
uint deadline
) external payable returns (uint tokenAmount, uint ethAmount, uint liquidity);
}
contract Evire is Context, IERC20, Ownable {
string private constant _tokenName = "Evire";
string private constant _tokenSymbol = "EVIRE";
uint8 private constant _tokenDecimals = 18;
uint256 private constant _totalSupply = 800000000 * 10**_tokenDecimals;
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
mapping(address => uint256) private _excludedAccounts;
uint256 private constant _minimumSwapAmount = 100000 * 10**_tokenDecimals;
uint256 private _maxSwapAmount = 5000000 * 10**_tokenDecimals;
uint256 public maxTransactionAmount = 800000 * 10**_tokenDecimals;
uint256 public maxWalletAmount = 1600000 * 10**_tokenDecimals;
uint256 private _initialBlockNumber;
uint256 buyTaxRate = 30;
uint256 sellTaxRate = 30;
IUniswapV2Router02 private _uniswapV2Router;
address public uniswapV2Pair;
address reserveWallet;
address infrastructureWallet;
address operationalWallet;
address developmentWallet;
bool private _tradingEnabled = false;
constructor() {
reserveWallet = 0xfCcA9Aea46E1cc5f8DFc2Eb827e6549f4Ea0bDAf;
infrastructureWallet = 0x0255319419559741B27512425a3f78CD2e5890EC;
operationalWallet = 0xE8d9B892400cDEF7Fa10275a35e5A7f7d4FFb207;
developmentWallet = 0x69C7D8c4f174426666414B46271a836b6f2BE24B;
_balances[msg.sender] = _totalSupply;
_excludedAccounts[msg.sender] = 1;
_excludedAccounts[address(this)] = 1;
emit Transfer(address(0), _msgSender(), _totalSupply);
}
function name() public pure returns (string memory) {
return _tokenName;
}
function symbol() public pure returns (string memory) {
return _tokenSymbol;
}
function decimals() public pure returns (uint8) {
return _tokenDecimals;
}
function totalSupply() public pure override returns (uint256) {
return _totalSupply;
}
function getTaxes() external view returns (uint256 buyTax, uint256 sellTax) {
buyTax = buyTaxRate;
sellTax = sellTaxRate;
}
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_executeTransfer(_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) {
_setAllowance(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_executeTransfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
unchecked {
_setAllowance(sender, _msgSender(), currentAllowance - amount);
}
}
return true;
}
function _setAllowance(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 enableTrading() external onlyOwner {
require(!_tradingEnabled, "Trading is already enabled");
_uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
_setAllowance(address(this), address(_uniswapV2Router), _totalSupply);
_uniswapV2Router.addLiquidityETH{value: address(this).balance}(
address(this),
balanceOf(address(this)),
0,
0,
owner(),
block.timestamp
);
IERC20(uniswapV2Pair).approve(address(_uniswapV2Router), type(uint).max);
_tradingEnabled = true;
_initialBlockNumber = block.number;
}
function updateExcludedAccount(address account, uint256 value) external onlyOwner {
_excludedAccounts[account] = value;
}
function removeLimits() external onlyOwner {
maxTransactionAmount = _totalSupply;
maxWalletAmount = _totalSupply;
}
function updateTaxes(uint256 newTaxRate) external onlyOwner {
require(newTaxRate <= buyTaxRate && newTaxRate <= sellTaxRate, "Tax cannot be increased");
buyTaxRate = newTaxRate;
sellTaxRate = newTaxRate;
}
function _executeTokenTransfer(address from, address to, uint256 amount, uint256 taxRate) private {
uint256 taxAmount = (amount * taxRate) / 100;
uint256 transferAmount = amount - taxAmount;
_balances[from] -= amount;
_balances[to] += transferAmount;
_balances[address(this)] += taxAmount;
emit Transfer(from, to, transferAmount);
}
function _executeTransfer(address from, address to, uint256 amount) private {
require(from != address(0), "ERC20: transfer from the zero address");
require(amount > 0, "ERC20: transfer amount must be greater than zero");
uint256 taxRate = 0;
if (_excludedAccounts[from] == 0 && _excludedAccounts[to] == 0) {
require(_tradingEnabled, "Trading is not enabled yet");
require(amount <= maxTransactionAmount, "Transaction amount exceeds the maximum limit");
if (to != uniswapV2Pair && to != address(0xdead)) {
require(balanceOf(to) + amount <= maxWalletAmount, "Recipient wallet exceeds the maximum limit");
}
if (block.number < _initialBlockNumber + 3) {
taxRate = (from == uniswapV2Pair) ? 30 : 30;
} else {
if (from == uniswapV2Pair) {
taxRate = buyTaxRate;
} else if (to == uniswapV2Pair) {
uint256 contractTokenBalance = balanceOf(address(this));
if (contractTokenBalance > _minimumSwapAmount) {
uint256 swapAmount = _maxSwapAmount;
if (contractTokenBalance > amount) contractTokenBalance = amount;
if (contractTokenBalance > swapAmount) contractTokenBalance = swapAmount;
_swapTokensForEth(contractTokenBalance);
}
taxRate = sellTaxRate;
}
}
}
_executeTokenTransfer(from, to, amount, taxRate);
}
function rescueEth() external onlyOwner {
(bool success, ) = owner().call{value: address(this).balance}("");
require(success, "Rescue ETH failed");
}
function rescueTokens() external onlyOwner {
uint256 contractTokenBalance = balanceOf(address(this));
require(contractTokenBalance > 0, "No tokens to rescue");
_executeTokenTransfer(address(this), owner(), contractTokenBalance, 0);
}
function manualSwap(uint256 percent) external onlyOwner {
uint256 contractTokenBalance = balanceOf(address(this));
uint256 swapAmount = (percent * contractTokenBalance) / 100;
_swapTokensForEth(swapAmount);
}
function _swapTokensForEth(uint256 tokenAmount) private {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = _uniswapV2Router.WETH();
_setAllowance(address(this), address(_uniswapV2Router), tokenAmount);
_uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(this),
block.timestamp
);
uint256 contractEthBalance = address(this).balance;
uint256 reserveTax = (contractEthBalance * 10) / 100;
uint256 infrastructureTax = (contractEthBalance * 30) / 100;
uint256 operationalTax = (contractEthBalance * 30) / 100;
uint256 developmentTax = (contractEthBalance * 30) / 100;
(bool success, ) = reserveWallet.call{value: reserveTax}("");
(success, ) = infrastructureWallet.call{value: infrastructureTax}("");
(success, ) = operationalWallet.call{value: operationalTax}("");
(success, ) = developmentWallet.call{value: developmentTax}("");
require(success, "Transfer failed");
}
receive() external payable {}
}