> ## Documentation Index
> Fetch the complete documentation index at: https://docs.galxe.com/llms.txt
> Use this file to discover all available pages before exploring further.

# LoyaltyPointFactory

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](https://explorer-sepolia.gravity.xyz/address/0x8a85eC5AE1ae2c757eEfBb10b1203C984120bf8c)
Gravity Alpha Mainnet: [0xd7B8c5f22f3589842f481EEb2d4F1F2f8CFc2038](https://explorer.gravity.xyz/address/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**

```solidity theme={null}
constructor(address _initialAdmin)
```

* **\_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.

  ```solidity theme={null}
  function pause() public onlyOwner;
  function unpause() public onlyOwner;
  ```

* **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**

  ```solidity theme={null}
  function createLoyaltyPoint(
    string calldata _name,
    string calldata _symbol,
    address _initialAdmin,
    address[] memory _minters
  ) external whenNotPaused returns (address contractAddr);
  ```

## **Usage Example**

To create a new loyalty point token:

```solidity theme={null}
address newLoyaltyPoint = factory.createLoyaltyPoint("Galxe Points", "GP", adminAddress, [minterAddress1, minterAddress2]);
```

## ABI

```json theme={null}
[
  {
    "type": "constructor",
    "inputs": [
      { "name": "_initialAdmin", "type": "address", "internalType": "address" },
      { "name": "_signer", "type": "address", "internalType": "address" }
    ],
    "stateMutability": "nonpayable"
  },
  {
    "type": "function",
    "name": "acceptOwnership",
    "inputs": [],
    "outputs": [],
    "stateMutability": "nonpayable"
  },
  {
    "type": "function",
    "name": "createLoyaltyPoint",
    "inputs": [
      { "name": "_spaceID", "type": "uint64", "internalType": "uint64" },
      { "name": "_version", "type": "string", "internalType": "string" },
      { "name": "_spaceName", "type": "string", "internalType": "string" },
      { "name": "_initialAdmin", "type": "address", "internalType": "address" },
      { "name": "_minters", "type": "address[]", "internalType": "address[]" },
      { "name": "_signature", "type": "bytes", "internalType": "bytes" }
    ],
    "outputs": [
      { "name": "contractAddr", "type": "address", "internalType": "address" }
    ],
    "stateMutability": "nonpayable"
  },
  {
    "type": "function",
    "name": "eip712Domain",
    "inputs": [],
    "outputs": [
      { "name": "fields", "type": "bytes1", "internalType": "bytes1" },
      { "name": "name", "type": "string", "internalType": "string" },
      { "name": "version", "type": "string", "internalType": "string" },
      { "name": "chainId", "type": "uint256", "internalType": "uint256" },
      {
        "name": "verifyingContract",
        "type": "address",
        "internalType": "address"
      },
      { "name": "salt", "type": "bytes32", "internalType": "bytes32" },
      { "name": "extensions", "type": "uint256[]", "internalType": "uint256[]" }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "getLoyaltyPoint",
    "inputs": [
      { "name": "_spaceID", "type": "uint64", "internalType": "uint64" }
    ],
    "outputs": [{ "name": "", "type": "address", "internalType": "address" }],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "loyaltyPointContracts",
    "inputs": [{ "name": "", "type": "uint64", "internalType": "uint64" }],
    "outputs": [{ "name": "", "type": "address", "internalType": "address" }],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "owner",
    "inputs": [],
    "outputs": [{ "name": "", "type": "address", "internalType": "address" }],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "pause",
    "inputs": [],
    "outputs": [],
    "stateMutability": "nonpayable"
  },
  {
    "type": "function",
    "name": "paused",
    "inputs": [],
    "outputs": [{ "name": "", "type": "bool", "internalType": "bool" }],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "pendingOwner",
    "inputs": [],
    "outputs": [{ "name": "", "type": "address", "internalType": "address" }],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "renounceOwnership",
    "inputs": [],
    "outputs": [],
    "stateMutability": "nonpayable"
  },
  {
    "type": "function",
    "name": "setSigner",
    "inputs": [
      { "name": "_signer", "type": "address", "internalType": "address" }
    ],
    "outputs": [],
    "stateMutability": "nonpayable"
  },
  {
    "type": "function",
    "name": "signer",
    "inputs": [],
    "outputs": [{ "name": "", "type": "address", "internalType": "address" }],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "transferOwnership",
    "inputs": [
      { "name": "newOwner", "type": "address", "internalType": "address" }
    ],
    "outputs": [],
    "stateMutability": "nonpayable"
  },
  {
    "type": "function",
    "name": "unpause",
    "inputs": [],
    "outputs": [],
    "stateMutability": "nonpayable"
  },
  {
    "type": "event",
    "name": "CreateLoyaltyPoint",
    "inputs": [
      {
        "name": "loyaltyPoint",
        "type": "address",
        "indexed": false,
        "internalType": "address"
      },
      {
        "name": "spaceID",
        "type": "uint64",
        "indexed": false,
        "internalType": "uint64"
      },
      {
        "name": "version",
        "type": "string",
        "indexed": false,
        "internalType": "string"
      },
      {
        "name": "spaceName",
        "type": "string",
        "indexed": false,
        "internalType": "string"
      },
      {
        "name": "initialAdmin",
        "type": "address",
        "indexed": false,
        "internalType": "address"
      },
      {
        "name": "minters",
        "type": "address[]",
        "indexed": false,
        "internalType": "address[]"
      }
    ],
    "anonymous": false
  },
  {
    "type": "event",
    "name": "EIP712DomainChanged",
    "inputs": [],
    "anonymous": false
  },
  {
    "type": "event",
    "name": "OwnershipTransferStarted",
    "inputs": [
      {
        "name": "previousOwner",
        "type": "address",
        "indexed": true,
        "internalType": "address"
      },
      {
        "name": "newOwner",
        "type": "address",
        "indexed": true,
        "internalType": "address"
      }
    ],
    "anonymous": false
  },
  {
    "type": "event",
    "name": "OwnershipTransferred",
    "inputs": [
      {
        "name": "previousOwner",
        "type": "address",
        "indexed": true,
        "internalType": "address"
      },
      {
        "name": "newOwner",
        "type": "address",
        "indexed": true,
        "internalType": "address"
      }
    ],
    "anonymous": false
  },
  {
    "type": "event",
    "name": "Paused",
    "inputs": [
      {
        "name": "account",
        "type": "address",
        "indexed": false,
        "internalType": "address"
      }
    ],
    "anonymous": false
  },
  {
    "type": "event",
    "name": "Unpaused",
    "inputs": [
      {
        "name": "account",
        "type": "address",
        "indexed": false,
        "internalType": "address"
      }
    ],
    "anonymous": false
  },
  { "type": "error", "name": "ECDSAInvalidSignature", "inputs": [] },
  {
    "type": "error",
    "name": "ECDSAInvalidSignatureLength",
    "inputs": [
      { "name": "length", "type": "uint256", "internalType": "uint256" }
    ]
  },
  {
    "type": "error",
    "name": "ECDSAInvalidSignatureS",
    "inputs": [{ "name": "s", "type": "bytes32", "internalType": "bytes32" }]
  },
  { "type": "error", "name": "EnforcedPause", "inputs": [] },
  { "type": "error", "name": "ExpectedPause", "inputs": [] },
  { "type": "error", "name": "InvalidAddress", "inputs": [] },
  { "type": "error", "name": "InvalidShortString", "inputs": [] },
  { "type": "error", "name": "InvalidSignature", "inputs": [] },
  {
    "type": "error",
    "name": "OwnableInvalidOwner",
    "inputs": [
      { "name": "owner", "type": "address", "internalType": "address" }
    ]
  },
  {
    "type": "error",
    "name": "OwnableUnauthorizedAccount",
    "inputs": [
      { "name": "account", "type": "address", "internalType": "address" }
    ]
  },
  {
    "type": "error",
    "name": "StringTooLong",
    "inputs": [{ "name": "str", "type": "string", "internalType": "string" }]
  }
]
```
