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.