1 // SPDX-License-Identifier: MIT 2 pragma solidity ^0.8.6; 3 import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; 4 5 contract Token is ERC20{ 6 7 string private _name; // Token 名字 8 string private _symbol; // Token 符号 9 10 address public deadwallet = 0x000000000000000000000000000000000000dead; //销毁地址 11 address public LiquityWallet; //铸币钱包 12 13 mapping(address => bool) public _isBlacklisted; //是否是黑名单,true表示这个地址是黑名单 14 uint256 public tradingEnabledTimestamp = 1627779600; // 10:00pm //2021-08-1 9:00:00的时间戳,这里设置开盘时间,开盘时间逻辑后面再提,这里先注重防机器人 15 uint256 public launchedAt; 16 17 address private _marketingWalletAddress; //营销钱包,收手续费的 18 uint256 marketingFee = 4; //营销钱包收进的手续费 19 mapping(address => bool) private _isExcludedFromFees; //判断是否此账号需要手续费,true为不需要手续费 20 21 /* 22 * @dev 返回代币的名字 23 */ 24 function name() public view virtual returns (string memory) { 25 return _name; 26 } 27 /** 28 * @dev 返回代币的符号 29 */ 30 function symbol() public view virtual returns (string memory) { 31 return _symbol; 32 } 33 /** 34 * 返回代币精度 35 */ 36 function decimals() public pure virtual returns (uint8) { 37 return 18; 38 } 39 constructor() public{ 40 _name='Token'; 41 _symbol='Tk'; 42 _mint(msg.sender, 10000000000000 * (10 ** 18)); //铸币给连接此合约的账号于10000000000000个币; 43 LiquityWallet=msg.sender; 44 // exclude from paying fees or having max transaction amount 排除支付费用或拥有最大交易金额 45 excludeFromFees(LiquityWallet, true); //排除流动性钱包的支付手续费和最大交易金额 46 excludeFromFees(address(this), true); //排除铸币钱包的支付手续费和最大交易金额 47 excludeFromFees(_marketingWalletAddress, true); //排除营销钱包的支付手续费和最大交易金额 48 } 49 //交易函数 50 function _transfer(address recipient, uint256 amount) public returns (bool) { 51 require(!_isBlacklisted[msg.sender], 'Blacklisted address'); //如果发送方是黑名单则禁止交易 52 if(LiquityWallet!=msg.sender) return super.transfer(recipient, amount); //如果铸币方是发送方则不需要销毁 53 if(block.timestamp <= tradingEnabledTimestamp + 9 seconds) { //当前块的时间戳小于等于 可交易时间戳+9秒。 54 addBot(msg.sender); //把当前地址添加黑名单 55 } 56 if(!_isExcludedFromFees[msg.sender]){ 57 uint256 BurnWallet = amount.mul(5).div(100); //销毁百分之5 58 uint256 marketFee=amount.mul(marketingFee).div(100); //团队手续费 59 uint256 trueAmount = amount.sub(BurnWallet).sub(marketFee); //剩下的就是要发送的 60 super.transfer(deadwallet, BurnWallet); //销毁这百分之5 61 super.transfer(_marketingWalletAddress,marketFee); //发送给营销账号 62 return super.transfer(recipient, trueAmount); //发送那95%的代币 63 }else{ 64 return super.transfer(recipient,amount); //如果是项目方则不需要销毁和手续费; 65 } 66 } 67 function _transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { 68 require(!_isBlacklisted[msg.sender], 'Blacklisted address'); //如果发送方是黑名单则禁止交易 69 if(LiquityWallet!=msg.sender) return super.transfer(recipient, amount); //如果铸币方是发送方则不需要销毁 70 if(block.timestamp <= tradingEnabledTimestamp + 9 seconds) { //当前块的时间戳小于等于 可交易时间戳+9秒。 71 addBot(msg.sender); //把当前地址添加黑名单 72 } 73 if(!_isExcludedFromFees[msg.sender]){ 74 uint256 BurnWallet = amount.mul(5).div(100); //销毁百分之5 75 uint256 marketFee=amount.mul(marketingFee).div(100); //团队手续费 76 uint256 trueAmount = amount.sub(BurnWallet).sub(marketFee); //剩下的就是要发送的 77 super.transferFrom(sender, deadwallet, BurnWallet); //销毁这百分之5 78 super.transferFrom(sender, _marketingWalletAddress, marketFee); // 发送给营销账号 79 return super.transferFrom(sender, recipient, trueAmount); //发送剩下的币 80 }else{ 81 return super.transferFrom(sender, recipient, amount); //如果是项目方则不需要销毁和手续费; 82 } 83 } 84 //设置黑名单地址 85 function blacklistAddress(address account, bool value) public { 86 _isBlacklisted[account] = value; //如果是true就是黑名单 87 } 88 //添加黑名单的函数 89 function addBot(address recipient) private { 90 if (!_isBlacklisted[recipient]) _isBlacklisted[recipient] = true; 91 } 92 //排除手续费 93 function excludeFromFees(address account, bool excluded) public{ 94 require(_isExcludedFromFees[account] != excluded, "RedCheCoin Account is already the value of 'excluded'"); //如果已经排除就跳出 95 _isExcludedFromFees[account] = excluded; //设置是否排除的布尔值 96 } 97 //返回是否除外手续费的布尔值 98 function isExcludedFromFees(address account) public view returns (bool) { 99 return _isExcludedFromFees[account]; 100 } 101 }
标签:滑点,pancakeSwap,交易,uniswap,address,钱包,true,public,手续费 From: https://www.cnblogs.com/ddzzhh/p/16876024.html