├── hardhat.config.ts ├── scripts └── deploy.ts ├── .gitignore ├── tsconfig.json ├── package.json ├── README.md └── contracts └── SurgeProtocolToken.sol /hardhat.config.ts: -------------------------------------------------------------------------------- 1 | import { HardhatUserConfig } from "hardhat/config"; 2 | import "@nomicfoundation/hardhat-toolbox"; 3 | import '@openzeppelin/contracts'; 4 | 5 | const config: HardhatUserConfig = { 6 | solidity: "0.8.17", 7 | }; 8 | 9 | export default config; 10 | -------------------------------------------------------------------------------- /scripts/deploy.ts: -------------------------------------------------------------------------------- 1 | import { ethers } from "hardhat"; 2 | 3 | async function main() { 4 | const TokenFactory = await ethers.getContractFactory("DanilychToken"); 5 | const token = await TokenFactory.deploy(3); 6 | 7 | await token.deployed(); 8 | } 9 | 10 | main().catch((error) => { 11 | console.error(error); 12 | process.exitCode = 1; 13 | }); 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .env 3 | coverage 4 | coverage.json 5 | typechain 6 | typechain-types 7 | 8 | # Hardhat files 9 | cache 10 | artifacts 11 | 12 | 13 | node_modules 14 | .env 15 | coverage 16 | coverage.json 17 | typechain 18 | typechain-types 19 | 20 | # Hardhat files 21 | cache 22 | artifacts 23 | 24 | 25 | node_modules 26 | .env 27 | coverage 28 | coverage.json 29 | typechain 30 | typechain-types 31 | 32 | # Hardhat files 33 | cache 34 | artifacts 35 | 36 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2020", 4 | "module": "commonjs", 5 | "declaration": true, 6 | "declarationMap": true, 7 | "sourceMap": true, 8 | "outDir": "./dist", 9 | "strict": true, 10 | "rootDirs": ["./src", "./scripts", "./test"], 11 | "esModuleInterop": true 12 | }, 13 | "exclude": ["dist", "node_modules"], 14 | "include": ["./test", "./src", "./scripts"], 15 | "files": ["./hardhat.config.ts"] 16 | } 17 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "deflationary-token", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "@openzeppelin/contracts": "^4.8.1" 14 | }, 15 | "devDependencies": { 16 | "@nomicfoundation/hardhat-toolbox": "^2.0.1", 17 | "hardhat": "^2.12.7" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Deflationary token 2 | 3 | This GitHub repository contains a smart contract for a deflationary token built using Solidity and Hardhat. The smart contract is designed to implement a token with a deflationary mechanism, where a portion of the tokens are burned with each transaction, leading to a decrease in the total supply of the token over time. 4 | 5 | The smart contract is built using Solidity, a programming language specifically designed for building smart contracts on the Ethereum blockchain. Hardhat is used as the development environment for the project, providing a powerful and flexible toolset for building and testing smart contracts. 6 | 7 | The deflationary mechanism is implemented through a "burn" function, which is called with each transaction. The burn function calculates a percentage of the tokens based on the transaction amount and burns them, removing them from circulation and reducing the total supply of the token. 8 | 9 | This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, and a script that deploys that contract. 10 | 11 | Try running some of the following tasks: 12 | 13 | ```shell 14 | npx hardhat help 15 | npx hardhat test 16 | REPORT_GAS=true npx hardhat test 17 | npx hardhat node 18 | npx hardhat run scripts/deploy.ts 19 | ``` 20 | -------------------------------------------------------------------------------- /contracts/SurgeProtocolToken.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.17; 3 | 4 | import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; 5 | import "@openzeppelin/contracts/access/Ownable.sol"; 6 | 7 | // Network: Ethereum 8 | // Name: SurgeProtocol 9 | // Token: SRG 10 | // TotalSupply: 1.5 billion 11 | 12 | contract SurgeProtocolToken is ERC20, Ownable { 13 | uint256 public txFee; 14 | address public taxWallet; 15 | mapping(address => bool) whitelists; 16 | 17 | constructor(uint256 txFee_, address taxWallet_) ERC20("SurgeProtocol", "SRG") { 18 | txFee = txFee_; 19 | taxWallet = taxWallet_; 20 | _mint(msg.sender, 15 * 10**8 * 10 ** decimals()); 21 | } 22 | 23 | function transfer( 24 | address to, 25 | uint256 amount 26 | ) public virtual override returns (bool) { 27 | if (whitelists[to] == false) { 28 | uint256 taxValue = (amount / 100) * txFee; 29 | _transfer(msg.sender, taxWallet, taxValue); 30 | _transfer(msg.sender, to, amount - taxValue); 31 | } 32 | else 33 | _transfer(msg.sender, to, amount); 34 | 35 | return true; 36 | } 37 | 38 | function transferFrom( 39 | address from, 40 | address to, 41 | uint256 amount 42 | ) public virtual override returns (bool) { 43 | address spender = _msgSender(); 44 | 45 | if (whitelists[from] == false && whitelists[to] == false) { 46 | uint256 taxValue = (amount / 100) * txFee; 47 | _transfer(from, taxWallet, taxValue); 48 | _spendAllowance(from, spender, amount); 49 | _transfer(from, to, amount - taxValue); 50 | return true; 51 | } 52 | else { 53 | _spendAllowance(from, spender, amount); 54 | _transfer(from, to, amount); 55 | return true; 56 | } 57 | } 58 | 59 | function changeFee(uint256 txFee_) external onlyOwner { 60 | txFee = txFee_; 61 | } 62 | 63 | function changeTaxWallet(address taxWallet_) external onlyOwner { 64 | taxWallet = taxWallet_; 65 | } 66 | 67 | function enableWhitelist(address whitelist_) external onlyOwner { 68 | whitelists[whitelist_] = true; 69 | } 70 | 71 | function disableWhitelist(address blacklist_) external onlyOwner { 72 | whitelists[blacklist_] = false; 73 | } 74 | } 75 | --------------------------------------------------------------------------------