Hooks are functions that can be added to the Loyalty Point contract to extend its functionality. They are executed during token transfers and can be used to implement custom logic, such as access control, rewards distribution, or external event triggers.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.
Creating a Hook
To create a hook, you need to implement theILoyaltyPointHook interface:
Deploying the Hook
Set up the environment variables:Setup hook on Loyalty Point contract
Set up necessary environment variables:PRIVATE_KEY: The private key of the admin account of the Loyalty Point contract.LOYALTY_POINT_ADDRESS: The address of the Loyalty Point contract.HOOK_ADDRESS: The address of the hook contract.
Testing the Hook
You can test the hook by minting or burning points to a user. The hook should be triggered and the event should be emitted.Example
An example of a hook that distributes rewards to a user has been deployed here. And here is a transaction that triggers the hook: 0xa4d01f742a1f532cecdb3b0c0a1a3b0922603cec4cf0edf46bd00c549ad03b75. In the transaction logs, you can see that the hook is called and thePointsUpdated event is emitted.