Note The UI/UX for shortcut hooks in Divvi apps is currently focused on “earn” and “claim rewards” use cases and requires a position pricing hook to be implemented as well. We plan to expand them to other use cases in the future (shortcuts with custom inputs, not linked to positions, or across dapps).
Developing a Shortcut Hook
Structure
Hooks are organized by application. For instance GoodDollar hooks are located inhttps://github.com/divvi-xyz/hooks/tree/main/src/apps/gooddollar
.
Shortcut hooks must implement the ShortcutsHook
TypeScript interface.
Creating a Shortcut Hook
To create a shortcut hook for your application namedMyApp
, you will need to create a new folder with the name my-app
in src/apps
and add a shortcuts.ts
file. The file should export an object with the following properties:
Implementing getShortcutDefinitions
The getShortcutDefinitions
function is called by a Divvi app to get the list of shortcuts.
It should return an array of ShortcutDefinition
objects.
GoodDollar Example
Here’s a simplified example of agetShortcutDefinitions
implementation for claiming GoodDollar rewards.
Please take a look at the full implementation for more details.
id
: the unique identifier for the shortcutname
: the title of the button used to trigger the shortcutdescription
: the description of the shortcutnetworks
: the networks the shortcut is available oncategory
: the category of the shortcutonTrigger
: the function that is called when the shortcut is triggered
availableShortcutIds
property to the position definition and setting the category
to claimable
for the appropriate token(s).
This way the Divvi app will be able to determine that the position has claimable token(s) and what shortcut to call to claim them.
Testing a Shortcut Hook
The hooks live preview mode in a Divvi app is the easiest way to test your shortcut hook while developing it. Alternatively, you can use the following scripts via the command line.List shortcuts
To see your shortcut hook, you can use thegetShortcuts
script.
List positions with linked shortcuts
To see positions linked to your shortcut hook, you can use with thegetPositions
script.
Trigger shortcuts
To test triggering your shortcut hook, you can use thetriggerShortcut
script.
--mnemonic
and --derivationPath
(defaults to the Celo derivation path: m/44'/52752'/0'/0/0
) options to actually sign and send the returned transaction(s).
Example for GoodDollar:
Suggest changes to this pageLast updated: Feb 19, 2025, 2:27 PM