ModuleSDK
Modules
Hook MultiPlexer

Hook MultiPlexer

The Hook MultiPlexer module is a module that allows you to add multiple hooks to a smart account if that is not supported and gives greater control over when these hooks are called.

You can find the source code for the module in the Core Modules repo (opens in a new tab) and the deployment address in the address book.

getHookMultiPlexer

The getHookMultiPlexer function is used to create an instance of the Hook MultiPlexer module. This function returns a module object.

import { getHookMultiPlexer, HookType } from "@rhinestone/module-sdk";
 
const params = {
  globalHooks: ['0x...', '0x...'], // hook addresses
  valueHooks: []
  delegatecallHooks: []
  sigHooks: [
    {
      sig: '0x...', // 4 byte hex string
      subHooks: '0x...' // hook address
    }
  ],
  targetHooks: []
  selector: '0x',
  hookType: HookType.GLOBAL
}
 
const hookMultiPlexer = getHookMultiPlexer(params);

getHooks

The getHooks function is used to get sub hooks installed on the Hook MultiPlexer. This function returns an array of hook addresses.

import { getHooks } from "@rhinestone/module-sdk";
 
const hooks = await getHooks({
  account,
  client
});

getAddHookAction

The getAddHookAction function is used to add a sub hook to the Hook MultiPlexer module. This function returns an execution object.

import { getAddHookAction, HookType } from "@rhinestone/module-sdk";
 
const addHookAction = getAddHookAction({
  hook: "0x...", // hook address
  hookType: HookType.GLOBAL,
  sig: "0x...", // 4 byte hex string required for installing SIG hook
});

getRemoveHookAction

The getRemoveHookAction function is used to remove a sub hook from the Hook MultiPlexer module. This function returns an execution object.

import { getRemoveHookAction, HookType } from "@rhinestone/module-sdk";
 
const removeHookAction = getRemoveHookAction({
  hook: "0x...", // hook address
  hookType: HookType.GLOBAL,
  sig: "0x...", // 4 byte hex string required for installing SIG hook
});

HOOK_MULTI_PLEXER_ADDRESS

The HOOK_MULTI_PLEXER_ADDRESS is a constant that represents the module address.