Token
Inherits: ERC20, AccessControl
Author: luoyhang003
ERC20 token with minting and blacklist transfer restrictions
Combines OpenZeppelin ERC20 and AccessControl
State Variables
MINTER_ROLE
Role identifier for minter accounts(contracts).
Calculated as keccak256("MINTER_ROLE").
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
OPERATOR_ROLE
Role identifier for operator accounts.
Calculated as keccak256("OPERATOR_ROLE").
bytes32 public constant OPERATOR_ROLE = keccak256("OPERATOR_ROLE");
accessRegistry
Reference to the access registry contract used for blacklist checks
Must implement the IAccessRegistry interface
IAccessRegistry public immutable accessRegistry;
Functions
constructor
Deploys the token and assigns DEFAULT_ADMIN_ROLE
constructor(address _admin, address _accessRegistry) ERC20("StakeStone USD", "SSUSD");
Parameters
| Name | Type | Description |
|---|---|---|
_admin | address | Address that will receive the default admin role |
_accessRegistry | address | Address of the access registry contract used for blacklist validation |
isBlacklisted
Checks whether a given address is blacklisted
function isBlacklisted(address _account) external view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
_account | address | The address to check |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if the address is blacklisted, false otherwise |
mint
Mint new tokens to a given address
Only callable by addresses with MINTER_ROLE
function mint(address _to, uint256 _amount) external onlyRole(MINTER_ROLE);
Parameters
| Name | Type | Description |
|---|---|---|
_to | address | The address to receive the minted tokens |
_amount | uint256 | The amount of tokens to mint |
burn
Burn tokens
function burn(uint256 _amount) external;
Parameters
| Name | Type | Description |
|---|---|---|
_amount | uint256 | The amount of tokens to burn |
_update
Overrides the _update function to enforce transfer restrictions
Prevents transfers if either sender or receiver is blacklisted
function _update(address _from, address _to, uint256 _amount) internal override;
Parameters
| Name | Type | Description |
|---|---|---|
_from | address | the address tokens are being transferred from |
_to | address | the address tokens are being transferred to |
_amount | uint256 | the amount of tokens being transferred |