文件 1 的 1:LOYAL.sol
pragma solidity 0.8.17;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this;
return 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;
}
}
interface IERC20 {
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);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
interface IERC20Metadata is IERC20 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
}
contract ERC20 is Context, IERC20, IERC20Metadata{
using SafeMath for uint256;
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 internal _totalSupply;
string private _name;
string private _symbol;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
function name() public view virtual override returns (string memory) {
return _name;
}
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
function decimals() public view virtual override returns (uint8) {
return 18;
}
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) {
_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) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount,
"BEP20: transfer amount exceeds allowance"));
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue,
"BEP20: decreased allowance below zero"));
return true;
}
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "BEP20: transfer from the zero address");
require(recipient != address(0), "BEP20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount,"BEP20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "BEP20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "BEP20: approve from the zero address");
require(spender != address(0), "BEP20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {}
}
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() {
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 virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
interface IERC721 {
function category() external view returns(uint256);
function _owner() external view returns(address payable);
function owner() external view returns(address);
function nftOwner(uint256 _id) external view returns (address);
function ownerOf(uint256 _id) external view returns (address);
function balanceOf(address account) external view returns (uint256);
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);
function totalSupply() external view returns (uint256);
function maxSupply() external view returns (uint256);
function getMintPrice() external view returns(uint256);
function safeBatchTransferFrom(
address from,
address to,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
) external;
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 value,
bytes calldata data
) external;
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
}
contract LOYAL is ERC20, Ownable {
using SafeMath for uint256;
address public DEAD = 0x000000000000000000000000000000000000dEaD;
IERC20 private $psyop = IERC20(0xaa07810aE08575921c476Ff088bc949da43e4964);
IERC721 private $PPJC = IERC721(0xEF22676fb3506b8d139F7552A1b30d172cA21410);
bool public tradingEnabled = false;
bool public psyopHoldersEnabled = true;
uint256 public MIN_PSYOPS = 69000000000000000000000000;
uint256 public MIN_PPJC = 1;
mapping(address => bool) private canTransferBeforeTradingIsEnabled;
mapping(address => bool) private isWhiteListed;
uint256 public launchtimestamp;
event SetPreSaleWallet(address wallet);
event TradingEnabled();
event Airdrop(address holder, uint256 amount);
constructor() ERC20("LOYAL by PPJC", "LOYAL") {
uint256 totalSupply = (69_000_000_000) * (10**18);
_mint(owner(), totalSupply);
canTransferBeforeTradingIsEnabled[owner()] = true;
canTransferBeforeTradingIsEnabled[address(this)] = true;
}
function decimals() public view virtual override returns (uint8) {
return 18;
}
receive() external payable {}
function enableTrading() external onlyOwner {
require(!tradingEnabled);
tradingEnabled = true;
launchtimestamp = block.timestamp;
emit TradingEnabled();
}
function psyopHoldersOnlyDisable(bool status) external onlyOwner {
require(!tradingEnabled, "LOYAL: Trading has not yet been enabled");
psyopHoldersEnabled = status;
}
function setCanTransferBefore(address wallet, bool enable) external onlyOwner {
canTransferBeforeTradingIsEnabled[wallet] = enable;
}
function setLimits(uint256 minPsyop, uint256 minPPJC) external onlyOwner {
MIN_PSYOPS = minPsyop;
MIN_PPJC = minPPJC;
}
function setWhiteLists(address[] memory wallets, bool allowed) external onlyOwner {
for(uint256 i; i < wallets.length; i++) {
isWhiteListed[wallets[i]] = allowed;
}
}
function Sweep() external onlyOwner {
uint256 amountETH = address(this).balance;
payable(msg.sender).transfer(amountETH);
}
function _transfer(address from, address to, uint256 amount) internal override {
require(from != address(0), "IERC20: transfer from the zero address");
require(to != address(0), "IERC20: transfer to the zero address");
if(psyopHoldersEnabled) {
if($psyop.balanceOf(to) >= MIN_PSYOPS || $PPJC.balanceOf(to) >= MIN_PPJC || isWhiteListed[to] == true || canTransferBeforeTradingIsEnabled[from]) {
} else {
require(tradingEnabled, "LOYAL: Trading has not yet been enabled");
}
}
if (amount == 0) {
super._transfer(from, to, 0);
return;
}
if (to == DEAD) {
super._transfer(from, to, amount);
_totalSupply = _totalSupply.sub(amount);
return;
}
super._transfer(from, to, amount);
}
function airdropToWallets(
address[] memory airdropWallets,
uint256[] memory amount
) external onlyOwner {
require(airdropWallets.length == amount.length, "Arrays must be the same length");
require(airdropWallets.length <= 200, "Wallets list length must be <= 200");
for (uint256 i = 0; i < airdropWallets.length; i++) {
address wallet = airdropWallets[i];
uint256 airdropAmount = amount[i] * (10**18);
super._transfer(msg.sender, wallet, airdropAmount);
}
}
}