├── tsconfig.json ├── package.json ├── scripts └── deploy.ts ├── README.md ├── LICENSE ├── contracts ├── Lock.sol └── SilverPhoenix.sol ├── hardhat.config.ts ├── .gitignore └── test └── Test.ts /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2020", 4 | "module": "commonjs", 5 | "esModuleInterop": true, 6 | "forceConsistentCasingInFileNames": true, 7 | "strict": true, 8 | "skipLibCheck": true, 9 | "resolveJsonModule": true 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hardhat-project", 3 | "devDependencies": { 4 | "@nomicfoundation/hardhat-toolbox": "^5.0.0", 5 | "@openzeppelin/contracts": "^5.1.0", 6 | "@uniswap/v2-core": "^1.0.1", 7 | "@uniswap/v2-periphery": "^1.1.0-beta.0", 8 | "hardhat": "^2.22.15" 9 | }, 10 | "dependencies": { 11 | "dotenv": "^16.4.5" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /scripts/deploy.ts: -------------------------------------------------------------------------------- 1 | // Importing necessary functionalities from the Hardhat package. 2 | import { ethers } from 'hardhat'; 3 | 4 | async function main() { 5 | console.log('Deploying contracts... Please wait.') 6 | const [deployer] = await ethers.getSigners(); 7 | console.log('Deploying contracts with the account:', deployer.address); 8 | const SilverPhoenix = await ethers.getContractFactory('SilverPhoenix'); 9 | const silverPhoenix = await SilverPhoenix.deploy(); 10 | await silverPhoenix.deployed(); 11 | console.log('SilverPhoenix contract is deployed to:', silverPhoenix.address); 12 | } 13 | 14 | // This pattern allows the use of async/await throughout and ensures that errors are caught and handled properly. 15 | main() 16 | .then(() => process.exit(0)) 17 | .catch((error) => { 18 | console.error(error); 19 | process.exit(1); 20 | }); 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Silver-Phoenix-contract 2 | 3 | Silver Phoenix is a Token contract on the Binance Smart Chain. 4 | It creates a token pair with Ethereum, and is a deflationary token. 5 | It also enable traders trading on the Binance Smart Chain. 6 | Fees on buying, selling and transferring are 4%. 7 | 8 | ## Token Information: 9 | - Token Name: Silver Phoenix 10 | - Token Symbol: SPX 11 | - Total Supply: 1e9 12 | - Token Decimals: 8 13 | - Token Type: BEP-20 14 | 15 | ## 📞 Contact & Support 16 | 17 | - **Email**: [imcrazysteven143@gmail.com](mailto:imcrazysteven143@gmail.com) 18 | - **GitHub**: [Steven (@imcrazysteven)](https://github.com/imcrazysteven) 19 | - **Telegram**: [@imcrazysteven](https://t.me/imcrazysteven) 20 | - **Twitter**: [@imcrazysteven](https://x.com/imcrazysteven) 21 | - **Instagram**: [@imcrazysteven](https://www.instagram.com/imcrazysteven/) 22 | 23 | --- 24 | 25 | [MIT](./LICENSE) -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Mitsuru Kudo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /contracts/Lock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.27; 3 | 4 | // Uncomment this line to use console.log 5 | // import "hardhat/console.sol"; 6 | 7 | contract Lock { 8 | uint public unlockTime; 9 | address payable public owner; 10 | 11 | event Withdrawal(uint amount, uint when); 12 | 13 | constructor(uint _unlockTime) payable { 14 | require( 15 | block.timestamp < _unlockTime, 16 | "Unlock time should be in the future" 17 | ); 18 | 19 | unlockTime = _unlockTime; 20 | owner = payable(msg.sender); 21 | } 22 | 23 | function withdraw() public { 24 | // Uncomment this line, and the import of "hardhat/console.sol", to print a log in your terminal 25 | // console.log("Unlock time is %o and block timestamp is %o", unlockTime, block.timestamp); 26 | 27 | require(block.timestamp >= unlockTime, "You can't withdraw yet"); 28 | require(msg.sender == owner, "You aren't the owner"); 29 | 30 | emit Withdrawal(address(this).balance, block.timestamp); 31 | 32 | owner.transfer(address(this).balance); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /hardhat.config.ts: -------------------------------------------------------------------------------- 1 | import { HardhatUserConfig } from "hardhat/config"; 2 | import "@nomicfoundation/hardhat-toolbox"; 3 | import "dotenv/config"; 4 | 5 | const infuraKey: string = process.env.INFURA_API_KEY as string; 6 | const privateKey: string = process.env.PRIVATE_KEY ? process.env.PRIVATE_KEY as string: ""; 7 | const etherscanKey: string = process.env.ETHERSCAN_KEY ? process.env.ETHERSCAN_KEY as string : ""; 8 | const basescanKey: string = process.env.BASESCAN_KEY ? process.env.BASESCAN_KEY as string : ""; 9 | const bscscanKey: string = process.env.BSCSCAN_KEY ? process.env.BSCSCAN_KEY as string : ""; 10 | 11 | const config: HardhatUserConfig = { 12 | solidity: { 13 | version: "0.8.27", 14 | settings: { 15 | optimizer: { 16 | enabled: true, 17 | runs: 100, 18 | }, 19 | // viaIR: true, 20 | }, 21 | }, 22 | networks: { 23 | eth_sepolia: { 24 | url: `https://sepolia.infura.io/v3/${infuraKey}`, 25 | accounts: [`0x${privateKey}`], 26 | }, 27 | eth_mainnet: { 28 | url: `https://mainnet.infura.io/v3/${infuraKey}`, 29 | accounts: [`0x${privateKey}`], 30 | }, 31 | base_sepolia: { 32 | url: "https://base-sepolia.blockpi.network/v1/rpc/public", 33 | accounts: [`0x${privateKey}`], 34 | }, 35 | base_mainnet: { 36 | url: "https://mainnet.base.org", 37 | accounts: [`0x${privateKey}`], 38 | }, 39 | holesky_testnet: { 40 | url: "https://ethereum-holesky-rpc.publicnode.com", 41 | accounts: [`0x${privateKey}`], 42 | }, 43 | bsc_mainnet: { 44 | url: "https://bsc-dataseed1.binance.org", 45 | chainId: 56, 46 | accounts: [`0x${privateKey}`], 47 | }, 48 | bsc_testnet: { 49 | url: "https://data-seed-prebsc-1-s1.binance.org:8545", 50 | chainId: 97, 51 | accounts: [`0x${privateKey}`], 52 | }, 53 | hardhat: { 54 | chainId: 31337, 55 | }, 56 | }, 57 | etherscan: { 58 | apiKey: { 59 | eth_mainnet: etherscanKey, 60 | eth_sepolia: etherscanKey, 61 | base_mainnet: basescanKey, 62 | base_sepolia: basescanKey, 63 | holesky: etherscanKey, 64 | bsc_testnet: bscscanKey 65 | }, 66 | }, 67 | gasReporter: { 68 | enabled: true, 69 | }, 70 | sourcify: { 71 | enabled: true, 72 | }, 73 | }; 74 | 75 | export default config; -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | .pnpm-debug.log* 9 | 10 | # Diagnostic reports (https://nodejs.org/api/report.html) 11 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 12 | 13 | # Runtime data 14 | pids 15 | *.pid 16 | *.seed 17 | *.pid.lock 18 | 19 | # Directory for instrumented libs generated by jscoverage/JSCover 20 | lib-cov 21 | 22 | # Coverage directory used by tools like istanbul 23 | coverage 24 | *.lcov 25 | 26 | # nyc test coverage 27 | .nyc_output 28 | 29 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 30 | .grunt 31 | 32 | # Bower dependency directory (https://bower.io/) 33 | bower_components 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (https://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules/ 43 | jspm_packages/ 44 | 45 | # Snowpack dependency directory (https://snowpack.dev/) 46 | web_modules/ 47 | 48 | # TypeScript cache 49 | *.tsbuildinfo 50 | 51 | # Optional npm cache directory 52 | .npm 53 | 54 | # Optional eslint cache 55 | .eslintcache 56 | 57 | # Optional stylelint cache 58 | .stylelintcache 59 | 60 | # Microbundle cache 61 | .rpt2_cache/ 62 | .rts2_cache_cjs/ 63 | .rts2_cache_es/ 64 | .rts2_cache_umd/ 65 | 66 | # Optional REPL history 67 | .node_repl_history 68 | 69 | # Output of 'npm pack' 70 | *.tgz 71 | 72 | # Yarn Integrity file 73 | .yarn-integrity 74 | 75 | # dotenv environment variable files 76 | .env 77 | .env.development.local 78 | .env.test.local 79 | .env.production.local 80 | .env.local 81 | 82 | # parcel-bundler cache (https://parceljs.org/) 83 | .cache 84 | .parcel-cache 85 | 86 | # Next.js build output 87 | .next 88 | out 89 | 90 | # Nuxt.js build / generate output 91 | .nuxt 92 | dist 93 | 94 | # Gatsby files 95 | .cache/ 96 | # Comment in the public line in if your project uses Gatsby and not Next.js 97 | # https://nextjs.org/blog/next-9-1#public-directory-support 98 | # public 99 | 100 | # vuepress build output 101 | .vuepress/dist 102 | 103 | # vuepress v2.x temp and cache directory 104 | .temp 105 | .cache 106 | 107 | # Docusaurus cache and generated files 108 | .docusaurus 109 | 110 | # Serverless directories 111 | .serverless/ 112 | 113 | # FuseBox cache 114 | .fusebox/ 115 | 116 | # DynamoDB Local files 117 | .dynamodb/ 118 | 119 | # TernJS port file 120 | .tern-port 121 | 122 | # Stores VSCode versions used for testing VSCode extensions 123 | .vscode-test 124 | 125 | # yarn v2 126 | .yarn/cache 127 | .yarn/unplugged 128 | .yarn/build-state.yml 129 | .yarn/install-state.gz 130 | .pnp.* 131 | 132 | node_modules 133 | .env 134 | 135 | # Hardhat files 136 | /cache 137 | /artifacts 138 | 139 | # TypeChain files 140 | /typechain 141 | /typechain-types 142 | 143 | # solidity-coverage files 144 | /coverage 145 | /coverage.json 146 | 147 | # Hardhat Ignition default folder for deployments against a local node 148 | ignition/deployments/chain-31337 149 | -------------------------------------------------------------------------------- /test/Test.ts: -------------------------------------------------------------------------------- 1 | import { expect } from "chai"; 2 | import { ethers } from "hardhat"; 3 | 4 | describe("SilverPhoenix", function () { 5 | let silverPhoenix: any; 6 | let owner: any; 7 | let addr1: any; 8 | let addr2: any; 9 | let feeReceiver: any; 10 | 11 | before(async function () { 12 | [owner, addr1, addr2, feeReceiver] = await ethers.getSigners(); 13 | 14 | const SilverPhoenix = await ethers.getContractFactory("SilverPhoenix"); 15 | silverPhoenix = await SilverPhoenix.deploy(); 16 | await silverPhoenix.waitForDeployment(); 17 | }); 18 | 19 | describe("Deployment", function () { 20 | it("Should set the right owner", async function () { 21 | expect(await silverPhoenix.owner()).to.equal(owner.address); 22 | }); 23 | 24 | it("Should have correct name and symbol", async function () { 25 | expect(await silverPhoenix.name()).to.equal("Silver Phoenix"); 26 | expect(await silverPhoenix.symbol()).to.equal("SPX"); 27 | }); 28 | 29 | it("Should have correct decimals", async function () { 30 | expect(await silverPhoenix.decimals()).to.equal(8); 31 | }); 32 | 33 | it("Should mint initial supply to owner", async function () { 34 | const totalSupply = await silverPhoenix.totalSupply(); 35 | expect(await silverPhoenix.balanceOf(owner.address)).to.equal(totalSupply); 36 | }); 37 | }); 38 | 39 | describe("Trading and Fees", function () { 40 | it("Should enable trading", async function () { 41 | await silverPhoenix.enableTrading(); 42 | // Try a transfer after enabling trading 43 | const amount = ethers.parseUnits("1000", 8); 44 | await silverPhoenix.transfer(addr1.address, amount); 45 | expect(await silverPhoenix.balanceOf(addr1.address)).to.be.gt(0); 46 | }); 47 | 48 | it("Should exclude address from fees", async function () { 49 | await silverPhoenix.excludeFromFees(addr1.address, true); 50 | expect(await silverPhoenix.isExcludedFromFees(addr1.address)).to.be.true; 51 | }); 52 | }); 53 | 54 | describe("Token Transfers", function () { 55 | beforeEach(async function () { 56 | await silverPhoenix.enableTrading(); 57 | }); 58 | 59 | it("Should transfer tokens between accounts", async function () { 60 | const amount = ethers.parseUnits("1000", 8); 61 | await silverPhoenix.transfer(addr1.address, amount); 62 | 63 | const addr1Balance = await silverPhoenix.balanceOf(addr1.address); 64 | // Account for 4% transfer fee 65 | expect(addr1Balance).to.equal(amount * 96n / 100n); 66 | }); 67 | 68 | it("Should fail when transferring more than balance", async function () { 69 | const initialBalance = await silverPhoenix.balanceOf(addr1.address); 70 | const excessAmount = initialBalance + ethers.parseUnits("1", 8); 71 | 72 | await expect( 73 | silverPhoenix.connect(addr1).transfer(addr2.address, excessAmount) 74 | ).to.be.reverted; 75 | }); 76 | }); 77 | 78 | describe("Emergency Functions", function () { 79 | it("Should allow owner to claim stuck tokens", async function () { 80 | const amount = ethers.parseUnits("1000", 8); 81 | await silverPhoenix.transfer(silverPhoenix.getAddress(), amount); 82 | await silverPhoenix.claimStuckTokens(await silverPhoenix.getAddress()); 83 | }); 84 | }); 85 | }); 86 | -------------------------------------------------------------------------------- /contracts/SilverPhoenix.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.27; 3 | 4 | import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; 5 | import "@openzeppelin/contracts/access/Ownable.sol"; 6 | import "@openzeppelin/contracts/utils/Context.sol"; 7 | import "@openzeppelin/contracts/utils/Address.sol"; 8 | import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol"; 9 | import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol"; 10 | import "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol"; 11 | 12 | contract SilverPhoenix is Context, Ownable, ERC20 { 13 | using Address for address payable; 14 | 15 | IUniswapV2Router02 public immutable uniswapV2Router; 16 | address public immutable uniswapV2Pair; 17 | 18 | /// @dev Fee settings 19 | uint8 feeBuy = 4; 20 | uint8 feeSell = 4; 21 | uint8 feeTransfer = 4; 22 | address feeReceiver = 0xA58f9ff087a85a9B2b1cF07492Dd4808f4835B9B; 23 | 24 | /// @dev Minimum amount of tokens accumulated with to swap to ETH/BNB 25 | uint256 swapTokenAmount; 26 | 27 | /// @dev Swap settings 28 | bool swapEnabled; 29 | bool swapping; 30 | bool tradingEnabled; 31 | 32 | mapping(address => bool) private _isExcludedFromFee; 33 | 34 | event FeeReceiverChanged( 35 | address indexed oldFeeReceiver, 36 | address indexed newFeeReceiver 37 | ); 38 | event SwapAmountChanged( 39 | uint256 indexed oldSwapAmount, 40 | uint256 indexed newSwapAmount 41 | ); 42 | event ExcludedFromFee(address indexed account, bool excluded); 43 | event SwapAndSendFee(uint256 tokenSwapped, uint256 bnbSend); 44 | 45 | constructor() ERC20("Silver Phoenix", "SPX") Ownable(msg.sender) { 46 | address router; 47 | address pinkLock; 48 | 49 | //Uniswap router address and pinklock address 50 | if (block.chainid == 56) { 51 | router = 0x10ED43C718714eb63d5aA57B78B54704E256024E; // BSC Pancake Mainnet Router 52 | pinkLock = 0x407993575c91ce7643a4d4cCACc9A98c36eE1BBE; // BSC PinkLock 53 | } else if (block.chainid == 97) { 54 | router = 0xD99D1c33F9fC3444f8101754aBC46c52416550D1; // BSC Pancake Testnet Router 55 | pinkLock = 0x5E5b9bE5fd939c578ABE5800a90C566eeEbA44a5; // BSC Testnet PinkLock 56 | } else if (block.chainid == 1 || block.chainid == 5) { 57 | router = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; // ETH Uniswap Mainnet % Testnet 58 | pinkLock = 0x71B5759d73262FBb223956913ecF4ecC51057641; // ETH PinkLock 59 | } else { 60 | revert(); 61 | } 62 | 63 | IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(router); 64 | address _uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) 65 | .createPair(address(this), _uniswapV2Router.WETH()); 66 | 67 | uniswapV2Router = _uniswapV2Router; 68 | uniswapV2Pair = _uniswapV2Pair; 69 | 70 | _approve(address(this), address(uniswapV2Router), type(uint256).max); 71 | 72 | //Exclude fee on specific account 73 | _mint(msg.sender, 1e9 * 10 ** decimals()); 74 | swapTokenAmount = totalSupply() / 5000; 75 | 76 | //Exclude fee on specific account 77 | _isExcludedFromFee[msg.sender] = true; 78 | _isExcludedFromFee[address(this)] = true; 79 | _isExcludedFromFee[feeReceiver] = true; 80 | _isExcludedFromFee[address(0)] = true; 81 | _isExcludedFromFee[pinkLock] = true; 82 | } 83 | 84 | /** 85 | * @dev Help function to return decimals 86 | */ 87 | function decimals() public view virtual override returns (uint8) { 88 | return 8; 89 | } 90 | 91 | /** 92 | * @dev internal function for transferring tokens 93 | * @param from The address of the sender 94 | * @param to The address of the recipient 95 | * @param amount The amount of tokens to transfer 96 | */ 97 | function _transfer( 98 | address from, 99 | address to, 100 | uint256 amount 101 | ) internal override { 102 | require(from != address(0), "ERC20: transfer from the zero address"); 103 | require(to != address(0), "ERC20: transfer to the zero address"); 104 | require(amount > 0, "Transfer amount must be greater than zero"); 105 | require( 106 | tradingEnabled || 107 | _isExcludedFromFee[from] || 108 | _isExcludedFromFee[to], 109 | "Trading is not enabled yet" 110 | ); 111 | 112 | //Swap SPX tokens accumulated with fee in contract to ETH/BNB 113 | uint256 accumulatedFeeTokenAmount = balanceOf(address(this)); 114 | bool canSwap = accumulatedFeeTokenAmount >= swapTokenAmount; 115 | 116 | if ( 117 | canSwap && 118 | swapEnabled && 119 | !swapping && 120 | to == uniswapV2Pair && 121 | !_isExcludedFromFee[from] 122 | ) { 123 | swapping = true; 124 | _swapAndSendFee(accumulatedFeeTokenAmount); 125 | swapping = false; 126 | } 127 | 128 | //Calculate fee and transfer tokens and fee 129 | uint256 totalFees; 130 | if (_isExcludedFromFee[from] || _isExcludedFromFee[to] || swapping) { 131 | totalFees = 0; 132 | } else if (from == uniswapV2Pair) { 133 | //Buy 134 | totalFees = feeBuy; 135 | } else if (to == uniswapV2Pair) { 136 | //Sell 137 | totalFees = feeSell; 138 | } else { 139 | //Transsfer 140 | totalFees = feeTransfer; 141 | } 142 | 143 | if (totalFees > 0) { 144 | uint256 feeTokenAmount = (amount * totalFees) / 100; 145 | amount = amount - feeTokenAmount; 146 | super._transfer(from, address(this), feeTokenAmount); 147 | } 148 | super._transfer(from, to, amount); 149 | } 150 | 151 | /** 152 | * @dev internal function for handling swap and send fee 153 | * @param tokenAmount The amount of tokens to swap and send 154 | */ 155 | function _swapAndSendFee(uint256 tokenAmount) internal { 156 | //Calculate initial balance 157 | uint256 initialBalance = address(this).balance; 158 | 159 | address[] memory path = new address[](2); 160 | path[0] = address(this); 161 | path[1] = uniswapV2Router.WETH(); 162 | 163 | //Swap tokens for ETH 164 | try 165 | uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( 166 | tokenAmount, 167 | 0, 168 | path, 169 | feeReceiver, 170 | block.timestamp 171 | ) 172 | {} catch { 173 | return; 174 | } 175 | //Calculate new balance 176 | uint256 newBalance = address(this).balance - initialBalance; 177 | 178 | //Send Fee to fee receiver 179 | payable(feeReceiver).sendValue(newBalance); 180 | emit SwapAndSendFee(tokenAmount, address(this).balance); 181 | } 182 | 183 | /** 184 | *@dev public function for changing fee receiver 185 | *@param newFeeReceiver_ The address of the new fee receiver 186 | */ 187 | function changeFeeReceiver(address newFeeReceiver_) external onlyOwner { 188 | address oldReceiver = feeReceiver; 189 | feeReceiver = newFeeReceiver_; 190 | emit FeeReceiverChanged(oldReceiver, feeReceiver); 191 | } 192 | 193 | /** 194 | *@dev claim stuck tokens from contract 195 | *@param token The address of the token to claim 196 | */ 197 | function claimStuckTokens(address token) external onlyOwner { 198 | if (token == address(0x0)) { 199 | payable(msg.sender).sendValue(address(this).balance); 200 | } 201 | IERC20(token).transfer( 202 | msg.sender, 203 | IERC20(token).balanceOf(address(this)) 204 | ); 205 | } 206 | 207 | /** 208 | *@dev exclude from fee 209 | *@param account The address of the account to exclude from fee 210 | *@param excluded Whether the account should be excluded from fee 211 | */ 212 | function excludeFromFees( 213 | address account, 214 | bool excluded 215 | ) external onlyOwner { 216 | _isExcludedFromFee[account] = excluded; 217 | emit ExcludedFromFee(account, excluded); 218 | } 219 | 220 | /** 221 | *@dev check if an account is excluded from fee 222 | *@param account The address of the account to check 223 | */ 224 | function isExcludedFromFees(address account) external view returns (bool) { 225 | return _isExcludedFromFee[account]; 226 | } 227 | 228 | /** 229 | *@dev set Swap Token Amount 230 | *@param newSwapTokenAmount The new swap token amount 231 | *@param _swapEnabled Whether to enable swap 232 | */ 233 | function setSwapTokenAmount( 234 | uint256 newSwapTokenAmount, 235 | bool _swapEnabled 236 | ) external onlyOwner { 237 | require( 238 | newSwapTokenAmount >= totalSupply() / 1_000_000, 239 | "Swap Token Amount must be greater than 0.0001% of total supply" 240 | ); 241 | uint256 oldSwapTokenAmount = swapTokenAmount; 242 | swapTokenAmount = newSwapTokenAmount; 243 | swapEnabled = _swapEnabled; 244 | emit SwapAmountChanged(oldSwapTokenAmount, newSwapTokenAmount); 245 | } 246 | 247 | /** 248 | *@dev enable trading and swap 249 | */ 250 | function enableTrading() external onlyOwner { 251 | require(!tradingEnabled, "Trading is already enabled"); 252 | tradingEnabled = true; 253 | swapEnabled = true; 254 | } 255 | 256 | receive() external payable {} 257 | } 258 | --------------------------------------------------------------------------------