Skip to main content
The LoyaltyPoint contract is the core contract for managing loyalty points. It defines the token logic, including minting and burning points (tokens), as well as role-based access control (RBAC) for managing permissions around minting.

Key Features

  • Minting and Burning Allows approved minters to mint and burn loyalty points.
  • ERC20 Compatibility This contract follows the ERC20 token standard, making it interoperable with other blockchain systems.
  • Role-based Access Control (RBAC) Uses role-based control to assign permissions to mint and burn points.
  • Custom Metadata Name and symbol for the loyalty point can be customized during deployment.

Constructor

  • _name Name of the loyalty point token (e.g., “Galxe Points”).
  • _symbol Token symbol (e.g., “GP”).
  • _initialAdmin Admin address responsible for managing permissions.
  • _minters An array of addresses with permission to mint points.

Role Management

  • The DEFAULT_ADMIN_ROLE is given to the _initialAdmin address.
  • The MINTER_ROLE is assigned to any addresses specified in the _minters array.
  • Admin can add or revoke roles using grantRole and revokeRole.

Minting and Burning

  • mint()
    Allows any address with the MINTER_ROLE to mint new points.
  • burn()
    Allows any address with the MINTER_ROLE to burn points from a specified account.

Usage Example

To mint new loyalty points to a user:
To burn loyalty points from a user:

Custom Events

  • Mint Emitted when new points are minted.
    • to: The address receiving the minted points.
    • amount: The amount of points minted.
  • Burn Emitted when points are burned.
    • from: The address from which points are burned.
    • amount: The amount of points burned.

Security

  • Pausable The contract can be paused and unpaused by the admin using the inherited Pausable functionality.
  • Access Control Implements role-based control using OpenZeppelin’s AccessControl.

ABI