Skip to content

Hook Definition

[Source]

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

A HookDefinition object describes a hook, which is a piece of code that is executed in response to certain transactions. The hook can modify the transaction, emit new transactions, or perform other actions.

{
"HookHash": "49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0",
"HookOn": "0000000000000000000000000000000000000000000000000000000000000000",
"HookNamespace": "0000000000000000000000000000000000000000000000000000000000000000",
"HookParameters": {
"HookParameter": {
"HookParameterName": "DEADBEEF",
"HookParameterValue": "DEADBEEF",
}
},
"HookApiVersion": 1,
"CreateCode": "5463C6E08862A1FAE5EDAC12D70ADB16546A1F674930521295BC082494B62924",
"HookSetTxnID": "0000000000000000",
"ReferenceCount": "6",
"Fee": "100000000",
"HookCallbackFee": "200000000",
"LedgerEntryType": "HookDefinition",
"index": "49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0"
}

A HookDefinition object has the following fields:

FieldJSON Type[Internal Type][]Required?Description
HookHashStringHash256YesThe unique identifier of the hook.
HookOnStringHash256YesThe transaction/s on which the hook is triggered.
HookCanEmitStringHash256NoThe transaction/s which the hook can emit.
HookNamespaceStringHash256YesThe namespace of the hook.
HookParametersStringVectorYesThe parameters that the hook accepts.
HookApiVersionNumberUInt16YesThe version of the hook API that the hook uses.
CreateCodeStringVLYesThe code that is executed when the hook is created.
HookSetTxnIDStringHash256YesThe ID of the transaction that set the hook.
ReferenceCountStringUInt64YesThe number of references to the hook.
FeeStringAmountYesThe fee for executing the hook.
HookCallbackFeeStringAmountNoThe fee for executing the hook’s callback function.
LedgerEntryTypeStringUInt16YesThe value 0x0043, mapped to the string HookDefinition, indicates that this object is a HookDefinition object.

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

  • The HookDefinition space key (0x0044)
  • The HookHash of the hook