Skip to content

Hook State

[Source]

(Added by the [Hooks amendment][].)

A HookState object describes the state of a hook, which is a piece of code running on Xahau that can interact with transactions. The HookState object stores the state of the hook, which can be modified by the hook’s code.

{
"OwnerNode": "0000000000000000",
"HookStateKey": "49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0",
"HookStateData": "46060241FABCF692D4D934BA2A6C4427CD4279083E38C77CBE642243E43BE291",
"LedgerEntryType": "HookState",
"index": "5463C6E08862A1FAE5EDAC12D70ADB16546A1F674930521295BC082494B62924"
}

A HookState object has the following fields:

FieldJSON Type[Internal Type][]Required?Description
OwnerNodeStringUInt64YesA hint indicating which page of the owner’s directory links to this object, in case the directory consists of multiple pages.
HookStateKeyStringHash256YesThe key that uniquely identifies this hook state.
HookStateDataStringVLYesThe data stored by the hook. This can be any data that the hook’s code decides to store.
LedgerEntryTypeStringUInt16YesThe value 0x0043, mapped to the string HookState, indicates that this object is a HookState object.

[Source]

The ID of a HookState object is the [SHA-512Half][] of the following values, concatenated in order:

  • The HookState space key (0x0076)
  • The AccountID of the account that owns the hook
  • The HookStateKey of the HookState object
  • The HookNamespace of the hook.