HookCreationDetails to account or contract creation and update transactions. Once attached, hooks can be deleted through update transactions and their storage can be modified via HookStoreTransaction. This page covers the utility classes, hook creation, update, and deletion across all supported transaction types.
Utility Classes
HookCreationDetails
Every hook requires aHookCreationDetails object that specifies the extension point, a unique hook ID, the EVM implementation contract, and an optional admin key.
HookExtensionPoint
EvmHook
EvmHookStorageUpdate
EvmHookStorageUpdate is an abstract type with two concrete implementations:
EvmHookStorageSlot
Directly sets a 32-byte key/value pair in the hook’s storage.EvmHookMappingEntries
Updates entries within a Solidity mapping at a specific storage slot.EvmHookMappingEntry
HookId and HookEntityId
Used byHookStoreTransaction to identify a specific hook on a specific entity.
Creating Hooks with New Entities
Hooks can be attached at entity creation time usingAccountCreateTransaction or ContractCreateTransaction.
AccountCreateTransaction Methods
ContractCreateTransaction Methods
Example: Create an Account with a Hook
Example: Create an Account with a Hook and Initial Storage
You can initialize hook storage at creation time by includingEvmHookStorageUpdate entries in the EvmHook.
Adding and Deleting Hooks on Existing Entities
UseAccountUpdateTransaction or ContractUpdateTransaction to add new hooks or remove existing hooks from an entity.
AccountUpdateTransaction Methods
ContractUpdateTransaction Methods
Example: Add Hooks to an Existing Account
Example: Delete Hooks from an Account
A hook can only be deleted when it has zero storage slots. Clear all storage first using
HookStoreTransaction (set values to empty bytes). If storage slots remain, the deletion fails with HOOK_DELETION_REQUIRES_EMPTY_STORAGE.An account cannot be deleted while it has hooks attached. CryptoDelete fails with TRANSACTION_REQUIRES_ZERO_HOOKS.