Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com> Co-authored-by: Eric Lau <ericglau@outlook.com> Co-authored-by: Zack Reneau-Wedeen <z.reneau.wedeen@gmail.com>
26 lines
830 B
Solidity
26 lines
830 B
Solidity
// SPDX-License-Identifier: MIT
|
|
pragma solidity ^0.8.20;
|
|
|
|
import {AccessControl} from "../../../access/AccessControl.sol";
|
|
import {ERC20} from "../../../token/ERC20/ERC20.sol";
|
|
|
|
contract AccessControlERC20MintBase is ERC20, AccessControl {
|
|
// Create a new role identifier for the minter role
|
|
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
|
|
|
|
error CallerNotMinter(address caller);
|
|
|
|
constructor(address minter) ERC20("MyToken", "TKN") {
|
|
// Grant the minter role to a specified account
|
|
_grantRole(MINTER_ROLE, minter);
|
|
}
|
|
|
|
function mint(address to, uint256 amount) public {
|
|
// Check that the calling account has the minter role
|
|
if (!hasRole(MINTER_ROLE, msg.sender)) {
|
|
revert CallerNotMinter(msg.sender);
|
|
}
|
|
_mint(to, amount);
|
|
}
|
|
}
|