AccessControlERC20MintOnlyRole.sol 763 B

1234567891011121314151617181920212223
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.20;
  3. import {AccessControl} from "../../../access/AccessControl.sol";
  4. import {ERC20} from "../../../token/ERC20/ERC20.sol";
  5. contract AccessControlERC20Mint is ERC20, AccessControl {
  6. bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
  7. bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE");
  8. constructor(address minter, address burner) ERC20("MyToken", "TKN") {
  9. _grantRole(MINTER_ROLE, minter);
  10. _grantRole(BURNER_ROLE, burner);
  11. }
  12. function mint(address to, uint256 amount) public onlyRole(MINTER_ROLE) {
  13. _mint(to, amount);
  14. }
  15. function burn(address from, uint256 amount) public onlyRole(BURNER_ROLE) {
  16. _burn(from, amount);
  17. }
  18. }