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 liveAsync iterator
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.
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
| Parameter | Type | Required | Description |
|---|---|---|---|
| from | string | No | Sender account. |
| account | string | No | Recipient account. |
| symbol | string | No | Asset or token symbol. |
| quantity | string | No | Exact amount, compared as a precision-safe decimal string. |
| actions | string[] | No | OR-matched trigger actions. Providing them requires a valid standardized trigger. |
| requireTrigger | boolean | No | Only emit transfers that carried a valid { action, metadata } trigger. |
Callbacks
| Parameter | Type | Required | Description |
|---|---|---|---|
| onSuccess | (payment) => void | Promise<void> | No | Payments whose success field is true. |
| onFailed | (payment) => void | Promise<void> | No | Payments whose success field is false. |
Execution checks
Important
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.
