Skip to content

ERC20Mintable

Git Source

Inherits: IERC20Mintable, Ownable2Step, ERC20Permit

An ERC20 token with controlled minting and burning capabilities.

Inherits from OpenZeppelin's ERC20, ERC20Permit, and Ownable2Step for secure ownership transfer. The owner has exclusive rights to mint and burn tokens, ensuring controlled supply management. Key Features:

  • Standard ERC20 functionality for token transfers and balances
  • EIP-2612 permit functionality for gasless approvals
  • Owner-restricted minting and burning of tokens
  • Two-step ownership transfer for enhanced security Security Considerations:
  • Only the owner can mint or burn tokens, preventing unauthorized supply changes.
  • Renouncing ownership is disabled to ensure the contract always has an owner for access control.

Functions

constructor

Initializes the ERC20Mintable token with metadata and sets the owner.

The owner address gets mint/burn privileges.

constructor(
    address owner,
    string memory name,
    string memory symbol
)
    Ownable(owner)
    ERC20(name, symbol)
    ERC20Permit(name);
Parameters
NameTypeDescription
owneraddressAddress to be set as the owner
namestringERC20 token name
symbolstringERC20 token symbol

mint

Mints new ERC20Mintable tokens to the specified address, increasing total supply.

Only callable by the owner. Increases both total supply and recipient balance. Requirements:

  • Caller must be the owner
  • to cannot be the zero address Emits:
  • {Mint} event with recipient and amount
  • {Transfer} event from zero address to recipient

Note: security: Owner-only access prevents unauthorized inflation

function mint(address to, uint256 amount) external onlyOwner;
Parameters
NameTypeDescription
toaddressAddress to receive the newly minted tokens
amountuint256Amount of tokens to mint

burn

Burns tokens from the specified address, decreasing total supply.

Only callable by the owner. Decreases both total supply and target balance. Requirements:

  • Caller must be the owner
  • from cannot be the zero address
  • from must have sufficient balance
  • If from is different from spender, spender must have allowance for from's tokens Emits:
  • {Burn} event with source address and amount
  • {Transfer} event from source address to zero address

Note: security: Owner-only access prevents unauthorized deflation

function burn(address from, address spender, uint256 amount) external onlyOwner;
Parameters
NameTypeDescription
fromaddressAddress to burn tokens from
spenderaddressAddress initiating the burn (for allowance checks if different from from)
amountuint256Amount of tokens to burn

renounceOwnership

Renouncing ownership is intentionally disabled for ERC20Mintable.

This function always reverts to ensure the contract always has an owner for mint/burn access control. This prevents accidental or malicious loss of administrative control.

Note: security: Always reverts to maintain ownership integrity

function renounceOwnership() public pure override;

Errors

RenounceOwnershipDisabled

Error thrown when attempting to renounce ownership.

ERC20Mintable intentionally disables ownership renunciation to ensure the contract always has an owner for mint/burn access control.

error RenounceOwnershipDisabled();