Skip to content
Alchemy Logo

serializeHookConfig

function serializeHookConfig(config): `0x${string}`;

Defined in: packages/smart-accounts/src/ma-v2/utils/hooks.ts:68

Serializes a HookConfig object into a Hex format by encoding the hook type, presence of post/pre hooks, address, and entity ID.

import { type HookType, serializeHookConfig } from "@alchemy/smart-accounts";
import { Address } from "viem";
 
const moduleAddress: Address = "0x1234";
const entityId: number = 1234;
const hookType: HookType = HookType.Validation;
const hasPostHooks: boolean = false;
const hasPreHooks: boolean = true;
 
const hookConfigHex = serializeHookConfig({
  moduleAddress,
  entityId,
  hookType,
  hasPostHooks,
  hasPreHooks,
});

ParameterTypeDescription

config

HookConfig

The hook configuration containing address, entity ID, hook type, and post/pre hook indicators

`0x${string}`

The serialized hook configuration in hexadecimal format

Was this page helpful?