Sepolia Testnet

Contract Diff Checker

Contract Name:
NOWCoin

Contract Source Code:

File 1 of 1 : NOWCoin

pragma solidity 0.5.16;

interface IERC20 {
    function totalSupply() external view returns (uint256);

    function decimals() external view returns (uint8);

    function symbol() external view returns (string memory);

    function name() external view returns (string memory);

    function getOwner() external view returns (address);

    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);

    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(
        address indexed owner,
        address indexed spender,
        uint256 value
    );
    event BlacklistUpdated(address indexed account, bool indexed enabled);
}

contract Context {
    constructor() internal {}

    function _msgSender() internal view returns (address payable) {
        return msg.sender;
    }

    function _msgData() internal view returns (bytes memory) {
        this;
        msg.data;
    }
}

library SafeMath {
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }

    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }

    function sub(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;
        return c;
    }

    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }

    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }

    function div(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        uint256 c = a / b;
        return c;
    }

    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }

    function mod(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
}

contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(
        address indexed previousOwner,
        address indexed newOwner
    );

    constructor() internal {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

    function owner() public view returns (address) {
        return _owner;
    }

    modifier onlyOwner() {
        require(_owner == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    function renounceOwnership() public onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }

    function transferOwnership(address newOwner) public onlyOwner {
        _transferOwnership(newOwner);
    }

    function _transferOwnership(address newOwner) internal {
        require(
            newOwner != address(0),
            "Ownable: new owner is the zero address"
        );
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
}

contract NOWCoin is Context, IERC20, Ownable {
    using SafeMath for uint256;
    struct LockBalance {
        uint256 Amount;
        uint256 UnlockTime;
    }

    mapping(address => uint256) private _balances;

    mapping(address => mapping(address => uint256)) private _allowances;

    mapping(address => LockBalance[]) public locks;

    mapping(address => bool) private _blacklisted;

    mapping(address => uint256) private _mintedTokens;

    uint256 private _totalSupply;
    uint8 private _decimals;
    string private _symbol;
    string private _name;
    address public airdropContract;
    uint256 public transferFee;
    address[] private _blacklist;

    constructor() public {
        _name = "NOW Coin";
        _symbol = "NOW";
        _decimals = 18;
        _totalSupply = 10000000000000000000000000000;
        _balances[msg.sender] = _totalSupply;
        emit Transfer(address(0), msg.sender, _totalSupply);
    }

    function getOwner() external view returns (address) {
        return owner();
    }

    function decimals() external view returns (uint8) {
        return _decimals;
    }

    function symbol() external view returns (string memory) {
        return _symbol;
    }

    function name() external view returns (string memory) {
        return _name;
    }

    function totalSupply() external view returns (uint256) {
        return _totalSupply;
    }

    function balanceOf(address account) external view returns (uint256) {
        return _balances[account];
    }

    function transfer(address recipient, uint256 amount)
        external
        returns (bool)
    {
        _transfer(_msgSender(), recipient, amount);
        return true;
    }

    function allowance(address owner, address spender)
        external
        view
        returns (uint256)
    {
        return _allowances[owner][spender];
    }

    function approve(address spender, uint256 amount) external returns (bool) {
        _approve(_msgSender(), spender, amount);
        return true;
    }

    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) external returns (bool) {
        _transfer(sender, recipient, amount);
        _approve(
            sender,
            _msgSender(),
            _allowances[sender][_msgSender()].sub(
                amount,
                "ERC20: transfer amount exceeds allowance"
            )
        );
        return true;
    }

    function increaseAllowance(address spender, uint256 addedValue)
        public
        returns (bool)
    {
        _approve(
            _msgSender(),
            spender,
            _allowances[_msgSender()][spender].add(addedValue)
        );
        return true;
    }

    function decreaseAllowance(address spender, uint256 subtractedValue)
        public
        returns (bool)
    {
        _approve(
            _msgSender(),
            spender,
            _allowances[_msgSender()][spender].sub(
                subtractedValue,
                "ERC20: decreased allowance below zero"
            )
        );
        return true;
    }

    function burn(uint256 amount) public returns (bool) {
        _burn(_msgSender(), amount);
        return true;
    }

    function getContractAddress() public view returns (address) {
        return address(this);
    }

    function lockBalance(
        address _account,
        uint256 _amount,
        uint256 _unlockTime
    ) external onlyOwner {
        for (uint256 i = 0; i < locks[_account].length; i++) {
            if (locks[_account][i].UnlockTime == _unlockTime) {
                locks[_account][i].Amount = locks[_account][i].Amount.add(
                    _amount
                );
                return;
            }
        }
        LockBalance memory lock = LockBalance(_amount, _unlockTime);
        locks[_account].push(lock);
    }

    function lockMultiBalance(
        address _account,
        uint256[] calldata _amounts,
        uint256[] calldata _unlockTimes
    ) external onlyOwner {
        require(
            _amounts.length == _unlockTimes.length,
            "Arrays length mismatch"
        );

        for (uint256 k = 0; k < _amounts.length; k++) {
            uint256 amount = _amounts[k];
            uint256 unlockTime = _unlockTimes[k];

            bool existingLockFound = false;
            for (uint256 i = 0; i < locks[_account].length; i++) {
                if (locks[_account][i].UnlockTime == unlockTime) {
                    locks[_account][i].Amount = locks[_account][i].Amount.add(
                        amount
                    );
                    existingLockFound = true;
                    break;
                }
            }
            if (!existingLockFound) {
                LockBalance memory lock = LockBalance(amount, unlockTime);
                locks[_account].push(lock);
            }
        }
    }

    function getLockedBalances(address account)
        external
        view
        returns (uint256[] memory, uint256[] memory)
    {
        uint256[] memory lockedAmounts = new uint256[](locks[account].length);
        uint256[] memory unlockTimes = new uint256[](locks[account].length);
        for (uint256 i = 0; i < locks[account].length; i++) {
            lockedAmounts[i] = locks[account][i].Amount;
            unlockTimes[i] = locks[account][i].UnlockTime;
        }
        return (lockedAmounts, unlockTimes);
    }

    function unlockBalance(address[] calldata accounts) external onlyOwner {
        for (uint256 i = 0; i < accounts.length; i++) {
            address account = accounts[i];
            uint256 totalUnlocked;
            for (uint256 j = 0; j < locks[account].length; j++) {
                if (locks[account][j].UnlockTime <= block.timestamp) {
                    totalUnlocked += locks[account][j].Amount;
                    delete locks[account][j];
                }
            }
            if (totalUnlocked > 0) {
                _transfer(address(this), account, totalUnlocked);
            }
        }
    }

    function setAirdropContract(address _airdropContract) public onlyOwner {
        airdropContract = _airdropContract;
    }

    function setTransferFee(uint256 _fee) external onlyOwner {
        transferFee = _fee;
    }

    function setBlacklistEnabled(address account, bool enabled)
        external
        onlyOwner
    {
        _blacklisted[account] = enabled;
        if (enabled == true) {
            _blacklist.push(account);
        }
        if (enabled == false) {
            for (uint256 i = 0; i < _blacklist.length; i++) {
                if (_blacklist[i] == account) {
                    _blacklist[i] = _blacklist[_blacklist.length - 1];
                    _blacklist.pop();
                    break;
                }
            }
        }
        emit BlacklistUpdated(account, enabled);
    }

    function setBlacklistEnabledMultiple(
        address[] calldata accounts,
        bool enabled
    ) external onlyOwner {
        for (uint256 i = 0; i < accounts.length; i++) {
            _blacklisted[accounts[i]] = enabled;
            if (enabled == true) {
                _blacklist.push(accounts[i]);
            }
            if (enabled == false) {
                for (uint256 j = 0; i < _blacklist.length; j++) {
                    if (_blacklist[j] == accounts[i]) {
                        _blacklist[j] = _blacklist[_blacklist.length - 1];
                        _blacklist.pop();
                        break;
                    }
                }
            }
            emit BlacklistUpdated(accounts[i], enabled);
        }
    }

    function isBlacklisted(address account) external view returns (bool) {
        return _blacklisted[account];
    }

    function getBlacklist() external view returns (address[] memory) {
        return _blacklist;
    }

    function mint(address account, uint256 amount) public onlyOwner {
        require(account != address(0), "ERC20: mint to the zero address");
        require(amount > 0, "ERC20: mint amount must be greater than 0");

        _totalSupply = _totalSupply.add(amount);
        _balances[account] = _balances[account].add(amount);
        _mintedTokens[account] = _mintedTokens[account].add(amount);

        emit Transfer(address(0), account, amount);
    }

    function _transfer(
        address sender,
        address recipient,
        uint256 amount
    ) internal {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");

        _balances[sender] = _balances[sender].sub(
            amount,
            "ERC20: transfer amount exceeds balance"
        );
        _balances[recipient] = _balances[recipient].add(amount);
        emit Transfer(sender, recipient, amount);
    }

    function _burn(address account, uint256 amount) internal {
        require(account != address(0), "ERC20: burn from the zero address");

        _balances[account] = _balances[account].sub(
            amount,
            "ERC20: burn amount exceeds balance"
        );
        _totalSupply = _totalSupply.sub(amount);
        emit Transfer(account, address(0), amount);
    }

    function _approve(
        address owner,
        address spender,
        uint256 amount
    ) internal {
        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 _burnFrom(address account, uint256 amount) internal {
        _burn(account, amount);
        _approve(
            account,
            _msgSender(),
            _allowances[account][_msgSender()].sub(
                amount,
                "ERC20: burn amount exceeds allowance"
            )
        );
    }
}

Please enter a contract address above to load the contract details and source code.

Context size (optional):