Token

Git Source

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

NameTypeDescription
_adminaddressAddress that will receive the default admin role
_accessRegistryaddressAddress 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

NameTypeDescription
_accountaddressThe address to check

Returns

NameTypeDescription
<none>boolTrue 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

NameTypeDescription
_toaddressThe address to receive the minted tokens
_amountuint256The amount of tokens to mint

burn

Burn tokens

function burn(uint256 _amount) external;

Parameters

NameTypeDescription
_amountuint256The 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

NameTypeDescription
_fromaddressthe address tokens are being transferred from
_toaddressthe address tokens are being transferred to
_amountuint256the amount of tokens being transferred