// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title El Nino Token * @dev ERC20 token implementation with additional features. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } abstract 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() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual 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"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function _transferOwnership(address newOwner) internal virtual { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract ElNinoToken is Ownable { string private _name; string private _symbol; uint8 private _decimals; uint256 private _totalSupply; mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint8 private _creatorTaxPercentage; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); constructor() { _name = "El Nino"; _symbol = "ELN"; _decimals = 18; _totalSupply = 100000000000000 * 10 ** uint256(_decimals); _balances[msg.sender] = _totalSupply; _creatorTaxPercentage = 5; emit Transfer(address(0), msg.sender, _totalSupply); } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used for token values. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev Returns the total supply of tokens. */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev Returns the balance of the specified address. * @param account The address to query the balance of. */ function balanceOf(address account) public view returns (uint256) { return _balances[account]; } /** * @dev Transfers tokens from the caller's account to another address. * @param recipient The address to transfer tokens to. * @param amount The amount of tokens to transfer. */ function transfer(address recipient, uint256 amount) public virtual returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev Transfers tokens from one address to another. * @param sender The address to transfer tokens from. * @param recipient The address to transfer tokens to. * @param amount The amount of tokens to transfer. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Sets the allowance for a spender on behalf of the caller. * @param spender The address to approve the allowance for. * @param amount The allowance amount. */ function approve(address spender, uint256 amount) public virtual returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev Returns the remaining allowance of tokens granted to a spender by the owner. * @param owner The address granting the allowance. * @param spender The address receiving the allowance. */ function allowance(address owner, address spender) public view virtual returns (uint256) { return _allowances[owner][spender]; } /** * @dev Increase the allowance for the spender. * @param spender The address to increase the allowance for. * @param addedValue The amount to increase the allowance by. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Decrease the allowance for the spender. * @param spender The address to decrease the allowance for. * @param subtractedValue The amount to decrease the allowance by. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } //** //* @dev Internal function to transfer tokens from one address to another.? function setCreatorTaxPercentage(uint256 _taxPercentage) public returns (bool success) { require(msg.sender == address(0xYourContractOwnerAddress), "Only contract owner can set the creator tax percentage"); require(_taxPercentage <= 100, "Tax percentage must be between 0 and 100"); creatorTaxPercentage = _taxPercentage; return true; } bool public isPaused; modifier whenNotPaused() { require(!isPaused, "Token transfers are paused"); _; } function pause() public returns (bool success) { require(msg.sender == address(0xYourContractOwnerAddress), "Only contract owner can pause token transfers"); isPaused = true; return true; } function unpause() public returns (bool success) { require(msg.sender == address(0xYourContractOwnerAddress), "Only contract owner can unpause token transfers"); isPaused = false; return true; } function transfer(address _to, uint256 _value) public whenNotPaused returns (bool success) { } event Burn(address indexed from, uint256 value); function burn(uint256 _value) public whenNotPaused returns (bool success) { require(balanceOf[msg.sender] >= _value, "Insufficient balance"); balanceOf[msg.sender] -= _value; totalSupply -= _value; emit Burn(msg.sender, _value); emit Transfer(msg.sender, address(0), _value); return true; } function multiTransfer(address[] memory _recipients, uint256[] memory _amounts) public whenNotPaused returns (bool success) { require(_recipients.length == _amounts.length, "Mismatched array lengths"); uint256 totalAmount = 0; for (uint256 i = 0; i < _recipients.length; i++) { require(_recipients[i] != address(0), "Invalid recipient address"); totalAmount += _amounts[i]; } require(balanceOf[msg.sender] >= totalAmount, "Insufficient balance"); for (uint256 i = 0; i < _recipients.length; i++) { address recipient = _recipients[i]; uint256 amount = _amounts[i]; balanceOf[msg.sender] -= amount; balanceOf[recipient] += amount; emit Transfer(msg.sender, recipient, amount); } return true; } function revokeAllowance(address _spender) public whenNotPaused returns (bool success) { require(allowance[msg.sender][_spender] > 0, "No allowance to revoke"); allowance[msg.sender][_spender] = 0; emit Approval(msg.sender, _spender, 0); return true; } function totalSupply() public view returns (uint256) { return totalSupply; } function transferOwnership(address newOwner) public { require(newOwner != address(0), "Invalid new owner address"); require(msg.sender == address(0xYourContractOwnerAddress), "Only contract owner can transfer ownership"); owner = newOwner; } function withdrawTokens(uint256 _amount) public { require(msg.sender == address(0xYourContractOwnerAddress), "Only contract owner can withdraw tokens"); require(balanceOf[address(this)] >= _amount, "Insufficient contract balance"); balanceOf[address(this)] -= _amount; balanceOf[msg.sender] += _amount; emit Transfer(address(this), msg.sender, _amount); } function transferAnyERC20Token(address _tokenAddress, address _to, uint256 _amount) public returns (bool success) { require(msg.sender == address(0xYourContractOwnerAddress), "Only contract owner can transfer any ERC20 tokens"); ERC20Interface token = ERC20Interface(_tokenAddress); return token.transfer(_to, _amount); } function rescueTokensFromContract(address _tokenAddress, address _to, uint256 _amount) public returns (bool success) { require(msg.sender == address(0xYourContractOwnerAddress), "Only contract owner can rescue tokens from the contract"); ERC20Interface token = ERC20Interface(_tokenAddress); return token.transfer(_to, _amount); } function() external payable { revert("Fallback function not allowed"); } function getDecimals() public view returns (uint8) { return decimals; } function getTokenOwner() public view returns (address) { return owner; } function getContractBalance() public view returns (uint256) { return address(this).balance; } function renounceOwnership() public { require(msg.sender == owner, "Only contract owner can renounce ownership"); owner = address(0); } function isContract(address _address) private view returns (bool) { uint256 size; assembly { size := extcodesize(_address) } return size > 0; } }
0.7.1