DineroERC20.sol
General Overview
The DineroERC20.sol
contract is an extension of the standard ERC20 token, incorporating additional features for minting and burning tokens in a permissioned manner. It achieves this by implementing access control mechanisms, which are governed by the MINTER_ROLE
and BURNER_ROLE
. These roles are crucial, as only accounts assigned with them are authorized to mint or burn tokens, respectively.
This controlled approach to token supply management is made possible through the integration of OpenZeppelin's AccessControlDefaultAdminRules
contract.
Technical Overview
Inherits: ERC20, AccessControlDefaultAdminRules
Author: redactedcartel.finance
State Variables
MINTER_ROLE
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
BURNER_ROLE
bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE");
Functions
constructor
constructor(string memory _name, string memory _symbol, uint8 _decimals, address _admin, uint48 _initialDelay)
AccessControlDefaultAdminRules(_initialDelay, _admin)
ERC20(_name, _symbol, _decimals);
Parameters
Name | Type | Description |
---|---|---|
_name | string | Token name |
_symbol | string | Token symbol |
_decimals | uint8 | Token decimals |
_admin | address | Admin address |
_initialDelay | uint48 | Delay required to schedule the acceptance of a access control transfer started |
mint
Mints tokens to an address
Only callable by minters
function mint(address _to, uint256 _amount) external onlyRole(MINTER_ROLE);
Parameters
Name | Type | Description |
---|---|---|
_to | address | Address to mint tokens to |
_amount | uint256 | Amount of tokens to mint |
burn
Burns tokens from an address
Only callable by burners
function burn(address _from, uint256 _amount) external onlyRole(BURNER_ROLE);
Parameters
Name | Type | Description |
---|---|---|
_from | address | Address to burn tokens from |
_amount | uint256 | Amount of tokens to burn |