HiveXPH SDKhivexph-sdk
NPM
Developer toolkit for Hive Custom JSON and Hive Engine transactions.

Payments

Payment stream

Turn the block stream into a live payment feed. Every transfer is normalized, filtered, and — for Hive Engine — checked against the sidechain execution logs before it is reported as successful.

Monitor payments live

Async iterator

TypeScript
const controller = new AbortController();

for await (const payment of hive.payments.watch({
  filters: { actions: ["purchase"] },
  onSuccess: (payment) => console.log("verified", payment.transfer.quantity),
  onFailed: (payment) => console.warn("failed", payment.error),
  signal: controller.signal,
})) {
  console.log(payment.status, payment.transfer, payment.trigger);
}

hive.payments.watch() is an async generator. Break the loop, abort the signal, or return from the function and the underlying block stream stops cleanly.

One block stream

hive.payments.watch() is a filtered view of the core block stream — the same reader behind hive.blocks.watch(), hive.customJson.watch() and hive.reader.stream(). Watching payments never opens a second blockchain connection.

TypeScript
for await (const payment of hive.payments.watch({
  fromBlock: 90_000_000,
  filters: { symbol: "MYTOKEN", actions: ["purchase"], requireTrigger: true },
  onSuccess: (payment) => fulfilOrder(payment.trigger?.metadata),
  onFailed: (payment) => console.warn(payment.error),
})) {
  console.log(payment.blockNumber, payment.status);
}

Filters

PaymentStreamFilters (all optional)
ParameterTypeRequiredDescription
fromstringNoSender account.
accountstringNoRecipient account.
symbolstringNoAsset or token symbol.
quantitystringNoExact amount, compared as a precision-safe decimal string.
actionsstring[]NoOR-matched trigger actions. Providing them requires a valid standardized trigger.
requireTriggerbooleanNoOnly emit transfers that carried a valid { action, metadata } trigger.

Callbacks

PaymentStreamOptions callbacks (all optional)
ParameterTypeRequiredDescription
onSuccess(payment) => void | Promise<void>NoPayments whose success field is true.
onFailed(payment) => void | Promise<void>NoPayments whose success field is false.

Execution checks

Important

A Hive Engine payment is only promoted to success: true after the stream queries the sidechain RPC and sees a transfer event in the execution logs. A log with an errors array becomes success: false; missing info keeps it pending.

Native HIVE / HBD payments are final once included in a block, so they move straight to success: true. Malformed memos never throw: the payment is emitted with trigger: null and filtered out when requireTrigger is enabled.