This preset contract affords an inheriting contract a set of standard functionality that enables ERC-20 functionality with role-based access control and pausable functions.
This preset contract is used by all ERC20 tokens in this project.
function __ERC20Preset_init_unchained() internal
Initializes the contract.
Grants the DEFAULT_ADMIN_ROLE
role and PAUSER_ROLE
role to the initializer.
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual
A hook that is called before a token transfer occurs.
Follows the rules of hooks defined here.
- The contract must not be paused.
Name | Type | Description |
---|---|---|
from | address | The address of the sender. |
to | address | The address of the recipient. |
amount | uint256 | The amount of tokens to transfer. |
function _approve(address owner, address spender, uint256 amount) internal virtual
See ERC20-approve for more details here.
This override applies the whenNotPaused
to the approve
, increaseAllowance
, decreaseAllowance
,
and _spendAllowance
(used by transferFrom
) functions.
- The contract must not be paused.
- Accounts cannot have allowance issued by their operators.
- If
value
is the maximumuint256
, the allowance does not updatetransferFrom
. This is semantically equivalent to an infinite approval. owner
cannot be the zero address.- The
spender
cannot be the zero address.
Name | Type | Description |
---|---|---|
owner | address | The owner of the tokens. |
spender | address | The address of the designated spender. This address is allowed to spend the tokens on behalf of the owner up to the amount value. |
amount | uint256 | The amount of tokens to afford the spender . |