Contract Source Code:
File 1 of 1 : PORKXToken
// SPDX-License-Identifier: MIT
// pragma solidity ^0.8.11;
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);
}
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data; }
}
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() {
_setOwner(_msgSender());
}
function owner() public view virtual returns (address) {
return _owner;
}
modifier onlyOwner() {
require(owner() == _msgSender(),
"Ownable: caller is not the owner");
_;
}
function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
library SafeMath {
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
function add(uint256 a,
uint256 b) internal pure returns (uint256) {
return a + b;
}
function sub(uint256 a,
uint256 b) internal pure returns (uint256) {
return a - b;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
function mod(uint256 a,
uint256 b) internal pure returns (uint256) {
return a % b;
}
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
function div(
uint256 a, uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}
interface IUniswapV2Factory {
function getPair(address tokenA, address tokenB) external view returns (address pair);
function createPair(address tokenA, address tokenB) external returns (address pair);
}
interface IUniswapV2Router02 {
function factory() external pure returns (address);
function WETH() external pure returns (address);
}
pragma solidity ^0.8.11;
contract PORKXToken is IERC20, Ownable {
using SafeMath for uint256;
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
mapping (address => bool) public isExcludedFromFee;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _totalSupply;
IUniswapV2Router02 public uniswapV2Router;
address public uniswapPair;
uint256 public _totalTaxIfBuying = 0;
uint256 public _totalTaxIfSelling = 0;
IUniswapV2Router02 _uniswapV2Router;
mapping(address => bool) public _isBlacklisted;
constructor(
string memory name_,
string memory symbol_,
uint256 totalSupply_,
address owner_
) payable {
_uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
_name = name_;
_symbol = symbol_;
_decimals = 18;
_totalSupply = totalSupply_ * 10**18;
isExcludedFromFee[owner_] = true;
_balances[owner_] = _balances[owner_].add(_totalSupply);
emit Transfer(address(0), owner_, _totalSupply);
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
function decimals() public view virtual returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
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;
}
/**
* @dev See {IERC20-allowance}.
*/
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,
"PORKX: 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,
"PORKX: decreased allowance below zero"
)
);
return true;
}
function _transfer(
address sender,
address recipient, uint256 amount
) internal virtual {
require(sender != address(0), "PORKX: transfer from the zero address");
require(recipient != address(0), "PORKX: transfer to the zero address");
require(!_isBlacklisted[sender], "Blacklisted");
_balances[sender] = _balances[sender].sub(amount,"PORKX: transfer amount exceeds balance");
uint256 finalAmount = (isExcludedFromFee[sender] || isExcludedFromFee[recipient]) ?
amount : takeFee(sender, recipient, amount);
_balances[recipient] = _balances[recipient].add(finalAmount);
emit Transfer(sender, recipient, finalAmount);
}
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "PORKX: approve from the zero address");
require(spender != address(0), "PORKX: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function excludeMultipleAccountsFromFees(address[] calldata accounts, bool excluded) public onlyOwner {
for(uint256 i = 0; i < accounts.length; i++) {
isExcludedFromFee[accounts[i]] = excluded;
}
}
function killBots(address[] calldata accounts,
bool excluded) public onlyOwner {
for (uint256 i = 0; i < accounts.length; i++) {
_isBlacklisted[accounts[i]] = excluded;
}
}
function setBuyDestFee(uint256 newBuyDestroyFee) public onlyOwner {
_totalTaxIfBuying = newBuyDestroyFee;
}
function setSellDestFee(uint256 newSellDestroyFee) public onlyOwner {
_totalTaxIfSelling = newSellDestroyFee;
}
function createLpPool() public onlyOwner {
address pair = IUniswapV2Factory(_uniswapV2Router.factory()).getPair(address(this), _uniswapV2Router.WETH());
if(pair == address(0)){
uniswapPair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
}
}
function takeFee(address sender, address recipient, uint256 amount) internal returns (uint256) {
uint256 feeAmount = 0;
if(uniswapPair == sender) {
feeAmount = amount.mul(_totalTaxIfBuying).div(100);
}
else if(uniswapPair == recipient) {
feeAmount = amount.mul(_totalTaxIfSelling).div(100);
}
if(feeAmount > 0) {
_balances[address(0)] = _balances[address(0)].add(feeAmount);
emit Transfer(sender, address(0), feeAmount);
}
return amount.sub(feeAmount);
}
}