From 9a704b2fe8b56d6797b03981d15d32d6ac28ccad Mon Sep 17 00:00:00 2001 From: "Vishal Tiwari (Believer)" Date: Fri, 4 Jul 2025 17:27:49 +0530 Subject: [PATCH 1/4] Create minting and burning token (smart contract) Description of Smart contract ... how it will work , just a basic overview of project --- minting and burning token (smart contract) | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 minting and burning token (smart contract) diff --git a/minting and burning token (smart contract) b/minting and burning token (smart contract) new file mode 100644 index 00000000..cc7d93c9 --- /dev/null +++ b/minting and burning token (smart contract) @@ -0,0 +1,11 @@ +Creating a basic Contract with deployment and test cases of Minting and Burning Token s + +1. Admin can assign a Minter Role and Burner Role and revert back their roles too +2.Minter can Mint tokens required +3. Burner can Burn tokens +4. Transfer of token can be made and it will give Admin a gas fee on every 1 million transfer of token + +Created using simpler framework Hardhat ...while u can also run and check on Replit + +for Hardhat (install) +npx hardhat \ No newline at end of file From dec6d69df76c31226ef428eab56c14a04d661883 Mon Sep 17 00:00:00 2001 From: "Vishal Tiwari (Believer)" Date: Fri, 4 Jul 2025 17:28:30 +0530 Subject: [PATCH 2/4] Update minting and burning token (smart contract) --- minting and burning token (smart contract) | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/minting and burning token (smart contract) b/minting and burning token (smart contract) index cc7d93c9..e69de29b 100644 --- a/minting and burning token (smart contract) +++ b/minting and burning token (smart contract) @@ -1,11 +0,0 @@ -Creating a basic Contract with deployment and test cases of Minting and Burning Token s - -1. Admin can assign a Minter Role and Burner Role and revert back their roles too -2.Minter can Mint tokens required -3. Burner can Burn tokens -4. Transfer of token can be made and it will give Admin a gas fee on every 1 million transfer of token - -Created using simpler framework Hardhat ...while u can also run and check on Replit - -for Hardhat (install) -npx hardhat \ No newline at end of file From 850fb8ff63deb2d021bcbc15e4f6ac94ec81abd7 Mon Sep 17 00:00:00 2001 From: "Vishal Tiwari (Believer)" Date: Fri, 4 Jul 2025 17:30:03 +0530 Subject: [PATCH 3/4] Create minting and burning/Readme.md just a basic overview of smart contract and what it does --- minting and burning/Readme.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 minting and burning/Readme.md diff --git a/minting and burning/Readme.md b/minting and burning/Readme.md new file mode 100644 index 00000000..cc7d93c9 --- /dev/null +++ b/minting and burning/Readme.md @@ -0,0 +1,11 @@ +Creating a basic Contract with deployment and test cases of Minting and Burning Token s + +1. Admin can assign a Minter Role and Burner Role and revert back their roles too +2.Minter can Mint tokens required +3. Burner can Burn tokens +4. Transfer of token can be made and it will give Admin a gas fee on every 1 million transfer of token + +Created using simpler framework Hardhat ...while u can also run and check on Replit + +for Hardhat (install) +npx hardhat \ No newline at end of file From 016ea5b619b38b26e4b71a66c1e92ddf80f6ca4f Mon Sep 17 00:00:00 2001 From: "Vishal Tiwari (Believer)" Date: Fri, 4 Jul 2025 17:32:39 +0530 Subject: [PATCH 4/4] Create Remix/MyToken.sol --- minting and burning/Remix/MyToken.sol | 42 +++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 minting and burning/Remix/MyToken.sol diff --git a/minting and burning/Remix/MyToken.sol b/minting and burning/Remix/MyToken.sol new file mode 100644 index 00000000..570e12c7 --- /dev/null +++ b/minting and burning/Remix/MyToken.sol @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.20; + +import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.9.0/contracts/token/ERC20/ERC20.sol"; +import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.9.0/contracts/access/AccessControl.sol"; + +contract MyToken is ERC20, AccessControl { + bytes32 public constant MINTER_ROLE = keccak256("MINTER"); + bytes32 public constant BURNER_ROLE = keccak256("BURNER"); + + address public admin; + + constructor() ERC20("MyCustomToken", "MCT") { + admin = msg.sender; + _grantRole(DEFAULT_ADMIN_ROLE, msg.sender); + } + + function mint(address to, uint256 amount) external onlyRole(MINTER_ROLE) { + _mint(to, amount); + } + + function burn(address from, uint256 amount) external onlyRole(BURNER_ROLE) { + _burn(from, amount); + } + + function _transfer(address from, address to, uint256 value) internal virtual override { + if (totalSupply() > 1_000_000 * 10 ** decimals()) { + uint256 fee = (value * 1) / 100; + super._transfer(from, admin, fee); + value -= fee; + } + super._transfer(from, to, value); + } + + function assignMinter(address account) external onlyRole(DEFAULT_ADMIN_ROLE) { + _grantRole(MINTER_ROLE, account); + } + + function assignBurner(address account) external onlyRole(DEFAULT_ADMIN_ROLE) { + _grantRole(BURNER_ROLE, account); + } +} \ No newline at end of file