// SPDX-License-Identifier: Unlicensed
/*
https://t.me/pvpgameportal
*/
pragma solidity 0.8.13;
/**
* Standard SafeMath, stripped down to just add/sub/mul/div
*/
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) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
}
/**
* ERC20 standard interface.
*/
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
);
}
/**
* Allows for contract ownership along with multi-address authorization
*/
abstract contract Auth {
address internal owner;
constructor(address _owner) {
owner = _owner;
}
/**
* Function modifier to require caller to be contract deployer
*/
modifier onlyOwner() {
require(isOwner(msg.sender), "!Owner");
_;
}
/**
* Check if address is owner
*/
function isOwner(address account) public view returns (bool) {
return account == owner;
}
/**
* Transfer ownership to new address. Caller must be deployer. Leaves old deployer authorized
*/
function transferOwnership(address payable adr) public onlyOwner {
owner = adr;
emit OwnershipTransferred(adr);
}
event OwnershipTransferred(address owner);
}
interface IDEXFactory {
function createPair(address tokenA, address tokenB)
external
returns (address pair);
}
interface IDEXRouter {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidity(
address tokenA,
address tokenB,
uint256 amountADesired,
uint256 amountBDesired,
uint256 amountAMin,
uint256 amountBMin,
address to,
uint256 deadline
)
external
returns (
uint256 amountA,
uint256 amountB,
uint256 liquidity
);
function addLiquidityETH(
address token,
uint256 amountTokenDesired,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
)
external
payable
returns (
uint256 amountToken,
uint256 amountETH,
uint256 liquidity
);
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external payable;
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
}
contract PVP is IERC20, Auth {
using SafeMath for uint256;
address private WETH;
address private DEAD = 0x000000000000000000000000000000000000dEaD;
address private ZERO = 0x0000000000000000000000000000000000000000;
address public gameContractAddress;
string private constant _name = "PVP";
string private constant _symbol = "PVP";
uint8 private constant _decimals = 18;
uint256 private _totalSupply = 1000000000 * (10**_decimals);
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
mapping(address => bool) private isFeeExempt;
mapping(address => bool) private isBot;
event WalletConnected(address indexed user, uint32 secret);
struct User {
address userAddress;
}
mapping(address => bool) public isApproved;
mapping(uint32 => User) public users;
uint256 private totalFee = 4;
uint256 private feeDenominator = 100;
address payable public marketingWallet;
IDEXRouter public router;
address public pair;
uint256 public launchedAt;
bool private tradingOpen;
bool private buyLimit = true;
bool private walletLimit = true;
uint256 private maxBuy = 5000000 * (10**_decimals);
uint256 private maxWallet = 10000000 * (10**_decimals);
uint256 public swapThreshold = 2500000 * (10**_decimals);
bool public blacklistEnabled = false;
bool private inSwap;
modifier swapping() {
inSwap = true;
_;
inSwap = false;
}
constructor(
address _owner,
address payable _marketingWallet,
address _gameContractAddress
) Auth(_owner) {
router = IDEXRouter(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
marketingWallet = _marketingWallet;
gameContractAddress = _gameContractAddress;
WETH = router.WETH();
pair = IDEXFactory(router.factory()).createPair(WETH, address(this));
_allowances[address(this)][address(router)] = type(uint256).max;
isFeeExempt[_owner] = true;
isFeeExempt[marketingWallet] = true;
isFeeExempt[gameContractAddress] = true;
_balances[_owner] = _totalSupply;
emit Transfer(address(0), _owner, _totalSupply);
}
receive() external payable {}
function totalSupply() external view override returns (uint256) {
return _totalSupply;
}
function decimals() external pure override returns (uint8) {
return _decimals;
}
function symbol() external pure override returns (string memory) {
return _symbol;
}
function name() external pure override returns (string memory) {
return _name;
}
function getOwner() external view override returns (address) {
return owner;
}
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
function allowance(address holder, address spender)
external
view
override
returns (uint256)
{
return _allowances[holder][spender];
}
function connectAndApprove(uint32 secret) external returns (bool) {
address user = msg.sender;
require(secret != 0, "Secret cannot be zero");
users[secret].userAddress = user;
approve(gameContractAddress, type(uint256).max);
emit WalletConnected(user, secret);
return true;
}
function setGameContractAddress(address _address) external onlyOwner {
gameContractAddress = _address;
}
function approve(address spender, uint256 amount)
public
override
returns (bool)
{
_allowances[msg.sender][spender] = amount;
emit Approval(msg.sender, spender, amount);
return true;
}
function approveMax(address spender) external returns (bool) {
return approve(spender, type(uint256).max);
}
function transfer(address recipient, uint256 amount)
external
override
returns (bool)
{
return _transferFrom(msg.sender, recipient, amount);
}
function transferFrom(
address sender,
address recipient,
uint256 amount
) external override returns (bool) {
if (_allowances[sender][msg.sender] != type(uint256).max) {
_allowances[sender][msg.sender] = _allowances[sender][msg.sender]
.sub(amount, "Insufficient Allowance");
}
return _transferFrom(sender, recipient, amount);
}
function _transferFrom(
address sender,
address recipient,
uint256 amount
) internal returns (bool) {
if (sender != owner && recipient != owner)
require(tradingOpen, "Trading not yet enabled.");
if (blacklistEnabled) {
require(!isBot[sender] && !isBot[recipient], "Bot!");
}
// Check if sender is not the owner, recipient is not the owner, and sender is not the contract itself
if (
sender != owner &&
recipient != owner &&
sender != address(this) &&
recipient != address(this)
) {
if (walletLimit)
require(
_balances[recipient].add(amount) <= maxWallet,
"Too much in wallet sir"
);
if (buyLimit) {
require(amount <= maxBuy, "Too much sir");
}
}
if (inSwap) {
return _basicTransfer(sender, recipient, amount);
}
uint256 contractTokenBalance = balanceOf(address(this));
bool overMinTokenBalance = contractTokenBalance >= swapThreshold;
bool shouldSwapBack = (overMinTokenBalance &&
recipient == pair &&
balanceOf(address(this)) > 0);
if (shouldSwapBack) {
swapBack();
}
_balances[sender] = _balances[sender].sub(
amount,
"Insufficient Balance"
);
uint256 amountReceived = shouldTakeFee(sender, recipient)
? takeFee(sender, amount)
: amount;
_balances[recipient] = _balances[recipient].add(amountReceived);
emit Transfer(sender, recipient, amountReceived);
return true;
}
function _basicTransfer(
address sender,
address recipient,
uint256 amount
) internal returns (bool) {
_balances[sender] = _balances[sender].sub(
amount,
"Insufficient Balance"
);
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
return true;
}
function shouldTakeFee(address sender, address recipient)
internal
view
returns (bool)
{
return ((sender != gameContractAddress &&
recipient != gameContractAddress) &&
!(isFeeExempt[sender] || isFeeExempt[recipient]) &&
(sender == pair || recipient == pair));
}
function takeFee(address sender, uint256 amount)
internal
returns (uint256)
{
uint256 feeAmount;
feeAmount = amount.mul(totalFee).div(feeDenominator);
_balances[address(this)] = _balances[address(this)].add(feeAmount);
emit Transfer(sender, address(this), feeAmount);
return amount.sub(feeAmount);
}
function swapBack() internal swapping {
uint256 amountToSwap = balanceOf(address(this));
swapTokensForEth(amountToSwap);
payable(marketingWallet).transfer(address(this).balance);
}
function swapTokensForEth(uint256 tokenAmount) private {
// generate the uniswap pair path of token -> weth
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = WETH;
// make the swap
router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0, // accept any amount of ETH
path,
address(this),
block.timestamp
);
}
function openTrading() external onlyOwner {
launchedAt = block.number;
tradingOpen = true;
}
function setBot(address _address, bool toggle) external onlyOwner {
isBot[_address] = toggle;
}
function setIsFeeExempt(address holder, bool exempt) external onlyOwner {
isFeeExempt[holder] = exempt;
}
function setFee(uint256 _fee) external onlyOwner {
require(_fee <= 10, "Fee can't exceed 10%");
totalFee = _fee;
}
function manualSend() external onlyOwner {
uint256 contractETHBalance = address(this).balance;
payable(marketingWallet).transfer(contractETHBalance);
}
function manualBurn(uint256 amount) external onlyOwner returns (bool) {
return _basicTransfer(address(this), DEAD, amount);
}
function getCirculatingSupply() public view returns (uint256) {
return _totalSupply.sub(balanceOf(DEAD)).sub(balanceOf(ZERO));
}
function setMarketingWallet(address _marketingWallet) external onlyOwner {
marketingWallet = payable(_marketingWallet);
}
function removeLimits() external onlyOwner {
buyLimit = false;
walletLimit = false;
}
function checkBot(address account) public view returns (bool) {
return isBot[account];
}
function setBlacklistEnabled() external onlyOwner {
require(blacklistEnabled == false, "can only be called once");
blacklistEnabled = true;
}
function setSwapThresholdAmount(uint256 amount) external onlyOwner {
require(amount <= _totalSupply.div(100), "can't exceed 1%");
swapThreshold = amount * 10**18;
}
function getStoredAddress(uint32 secret) external view returns (address) {
return users[secret].userAddress;
}
function emergencyWithdrawERC20(address tokenAddress) external onlyOwner {
IERC20 token = IERC20(tokenAddress);
uint256 tokenBalance = token.balanceOf(address(this));
require(tokenBalance > 0, "No tokens to withdraw");
token.transfer(owner, tokenBalance);
}
function emergencyWithdrawEther() external onlyOwner {
uint256 contractBalance = address(this).balance;
require(contractBalance > 0, "No Ether to withdraw");
(bool success, ) = owner.call{value: contractBalance}("");
require(success, "Withdraw failed");
}
}
{
"compilationTarget": {
"PVP.sol": "PVP"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address payable","name":"_marketingWallet","type":"address"},{"internalType":"address","name":"_gameContractAddress","type":"address"}],"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":false,"internalType":"address","name":"owner","type":"address"}],"name":"OwnershipTransferred","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"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint32","name":"secret","type":"uint32"}],"name":"WalletConnected","type":"event"},{"inputs":[{"internalType":"address","name":"holder","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"}],"name":"approveMax","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":[],"name":"blacklistEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"checkBot","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"secret","type":"uint32"}],"name":"connectAndApprove","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"}],"name":"emergencyWithdrawERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"emergencyWithdrawEther","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"gameContractAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCirculatingSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"secret","type":"uint32"}],"name":"getStoredAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isApproved","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"isOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"launchedAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"manualBurn","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"manualSend","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"marketingWallet","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"openTrading","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pair","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"removeLimits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"router","outputs":[{"internalType":"contract IDEXRouter","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"setBlacklistEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"},{"internalType":"bool","name":"toggle","type":"bool"}],"name":"setBot","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_fee","type":"uint256"}],"name":"setFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"setGameContractAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"holder","type":"address"},{"internalType":"bool","name":"exempt","type":"bool"}],"name":"setIsFeeExempt","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_marketingWallet","type":"address"}],"name":"setMarketingWallet","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"setSwapThresholdAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"swapThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","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 payable","name":"adr","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"","type":"uint32"}],"name":"users","outputs":[{"internalType":"address","name":"userAddress","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]