Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed ERC20Pausable, AccessControl and minting #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 3 additions & 59 deletions contracts/YourToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,76 +3,20 @@ pragma solidity 0.8.23;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";


/**
* @title YOUR Token (YOUR)
* @dev ERC20 Token with more benefits, including minting, burning,
* access control, and pausable functionality.
*/
contract YourToken is ERC20, ERC20Burnable, ERC20Pausable, AccessControl, ERC20Permit {

// Roles for access control
bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");

contract YourToken is ERC20, ERC20Burnable, ERC20Permit {
/**
* @dev Contract constructor.
* @param defaultAdmin The default admin for the contract.
* @param initialOwner The initial owner who receives the initial token supply.
*/
constructor(address defaultAdmin, address initialOwner)
constructor()
ERC20("YOUR AI", "YOURAI")
ERC20Permit("YOUR AI")
{
// Validate that initialOwner and defaultAdmin are not the zero address
require(initialOwner != address(0), "Initial owner cannot be the zero address");
require(defaultAdmin != address(0), "Default admin cannot be the zero address");

// Assign roles and mint initial token supply to the initial owner
_grantRole(DEFAULT_ADMIN_ROLE, defaultAdmin);
_grantRole(PAUSER_ROLE, defaultAdmin);
_grantRole(MINTER_ROLE, defaultAdmin);
_mint(initialOwner, 1000000000 * 10 ** decimals()); // Initial supply deposited to the address provided here
}

/**
* @dev Pause token transfers.
* Only callable by an address with the PAUSER_ROLE.
*/
function pause() public onlyRole(PAUSER_ROLE) {
_pause();
}

/**
* @dev Unpause token transfers.
* Only callable by an address with the PAUSER_ROLE.
*/
function unpause() public onlyRole(PAUSER_ROLE) {
_unpause();
}

/**
* @dev Mint new tokens and assign them to the specified address.
* Only callable by an address with the MINTER_ROLE.
* @param to The address to which new tokens will be minted.
* @param amount The amount of tokens to mint.
*/
function mint(address to, uint256 amount) public onlyRole(MINTER_ROLE) {
_mint(to, amount);
}

/**
* @dev Internal function to update token transfers.
* Overrides functions from ERC20 and ERC20Pausable.
*/
function _update(address from, address to, uint256 value)
internal
override(ERC20, ERC20Pausable)
{
super._update(from, to, value);
_mint(msg.sender, 1_000_000_000 * 10 ** decimals()); // Initial supply deposited to the address provided here
}
}
8 changes: 1 addition & 7 deletions deploy/YourToken.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,7 @@ async function main() {
console.log("Network name :", network.name);
console.log("Network chain id :", network.chainId);

const adminAddress = "0x3Ec5faF545030cdE1f3D887F876061e0B0Ffa1a0";
const tokenHoldingAddress = "0x3Ec5faF545030cdE1f3D887F876061e0B0Ffa1a0";

const contractDeployer1 = await ethers.deployContract("YourToken", [
adminAddress, // Initial Admin
tokenHoldingAddress, // Initial Owner holding all tokens
]);
const contractDeployer1 = await ethers.deployContract("YourToken");

if (contractDeployer1.waitForDeployment()) {
console.log("ERC20 Token Deployed :", await contractDeployer1.getAddress());
Expand Down