Skip to content

Latest commit

 

History

History
83 lines (50 loc) · 2.49 KB

ERC20Preset.md

File metadata and controls

83 lines (50 loc) · 2.49 KB

ERC20Preset

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.

Inherits:

__ERC20Preset_init_unchained

function __ERC20Preset_init_unchained() internal

Initializes the contract.

Grants the DEFAULT_ADMIN_ROLE role and PAUSER_ROLE role to the initializer.

_beforeTokenTransfer

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.

Requirements:
  • 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.

_approve

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.

Requirements:
  • The contract must not be paused.
  • Accounts cannot have allowance issued by their operators.
  • If value is the maximum uint256, the allowance does not update transferFrom. 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.