Reference Counting

Avoid re-uploading the same bytecode to the ledger

Reference Counted Hook Definitions

When a novel Hook's web assembly byte-code is uploaded to the XRP Ledger a significant storage burden is imposed on the network. This storage burden is reflected in the Hook Fees charged by the network.

To avoid this burden (and high fees for end users) reference counting is used:

  • The first time a novel Hook is installed the SetHook Transaction is must provide a significant fee.
  • The Hook's web assembly byte-code becomes a unowned and reference counted object on the ledger (called a HookDefinition).
  • Subsequent installations by the same or other users for an identical Hook (i.e. with identical byte-code) increment the reference count. These installations point at the same object on the ledger. These transactions are billed in a similar way to setting a Trustline, as the storage burden for the Hook was already paid for in the original Set Hook transaction.
  • While the reference count on the Hook Definition is greater than zero (meaning one or more accounts still have the Hook installed) the object remains on the ledger.
691691

What’s Next