Skip to main content
The LoyaltyPointFactory contract is responsible for deploying new instances of the LoyaltyPoint contract. It serves as a factory pattern for creating customizable loyalty point tokens with specific configurations.

Addresses

Gravity Alpha Testnet Sepolia: 0x8a85eC5AE1ae2c757eEfBb10b1203C984120bf8c Gravity Alpha Mainnet: 0xd7B8c5f22f3589842f481EEb2d4F1F2f8CFc2038

Key Features

  • Role Management Admin rights are granted to a specified initial admin.
  • Pause/Unpause Functionality Provides the ability to pause and unpause contract functions for security and maintenance.
  • Salted Deployment Uses create2 to ensure deterministic contract addresses based on provided salt.

Constructor

  • _initialAdmin: This is the address assigned as the administrator of the contract and any loyalty point contracts created by it.
  • The constructor checks whether the provided admin address is valid (i.e., non-zero). If the address is invalid, the contract throws an InvalidAddress() error.

Events

  • CreateLoyaltyPoint Emitted when a new LoyaltyPoint contract is created.
    • loyaltyPoint: The address of the newly deployed LoyaltyPoint contract.
    • name: The name of the loyalty point token (e.g., “Galxe Points”).
    • symbol: The symbol of the loyalty point token (e.g., “GP”).
    • initialAdmin: The address that will serve as the admin of the new loyalty point contract.
    • minters: An array of addresses that have the permission to mint loyalty points.

Key Functions

  • pause() / unpause()
    These functions allow the owner to pause or unpause contract execution for security purposes.
  • createLoyaltyPoint()
    This function deploys a new instance of the LoyaltyPoint contract using the create2 opcode, which allows for a deterministic address based on the contract’s salt (a hash of the name and symbol). The initial admin and minting addresses are also passed to the new contract.
    Parameters
    • _name: The name of the loyalty point token.
    • _symbol: The symbol for the loyalty point token.
    • _initialAdmin: The admin address for the new contract.
    • _minters: An array of addresses that will have permission to mint tokens in the new contract.
    Returns
    • contractAddr: The address of the newly created loyalty point contract.
    Code Example

Usage Example

To create a new loyalty point token:

ABI