Skip to main content
Hooks are created by adding 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 a HookCreationDetails 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 by HookStoreTransaction to identify a specific hook on a specific entity.

Creating Hooks with New Entities

Hooks can be attached at entity creation time using AccountCreateTransaction 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 including EvmHookStorageUpdate entries in the EvmHook.

Adding and Deleting Hooks on Existing Entities

Use AccountUpdateTransaction 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.

Atomic Delete and Recreate

To support atomic hook updates (e.g., for compliance), you can delete and recreate a hook with the same ID in a single update transaction. Deletions are processed first, then creations.

Transaction Signing Requirements


Error Codes