Receipt message to a dedicated HCS topic. The ReceiptLedger class reads those messages and, when you call audit(), cross-checks each receipt against the actual Hedera transaction on the mirror node. This gives both buyers and sellers a tamper-evident, on-chain billing trail that neither party can retroactively alter — without storing any data in a centralised database.
Installation and Import
Constructor
Options
'testnet' | 'mainnet'
required
The Hedera network the receipts topic lives on. Controls which mirror node is queried when
mirrorUrl is not set.string
required
The HCS topic ID where the seller publishes receipts, in
shard.realm.num format. You can find this value in the seller’s ServiceListing.receiptsTopicId field.string
Override the Hedera mirror node REST base URL. Defaults to the standard Hashio endpoint for the chosen network.
typeof fetch
Custom
fetch implementation. Defaults to the global fetch. Useful in test environments or when routing through a proxy.Methods
list(opts?)
Receipt messages from the HCS topic. Messages that do not parse as a Receipt are skipped silently.
string
Filter to messages whose HCS consensus timestamp is strictly after this value. Use the ISO-style consensus timestamp string returned by a previous call (e.g.
"1700000000.123456789") to page forward through the log incrementally.Receipt
The parsed receipt object. See the Receipt fields reference below.
string
The HCS consensus timestamp at which the receipt message was finalised, in Hedera’s
seconds.nanoseconds format.number
The topic sequence number of this message. Sequence numbers are monotonically increasing, so you can use them to detect gaps.
string
The Hedera account that paid for the HCS message. Cross-check this against
receipt.payTo to verify that the seller, not an impersonator, wrote this receipt.audit(opts?)
list() internally, then fetches the corresponding Hedera transaction from the mirror node for each receipt and verifies that the on-chain transfer matches the receipt’s claimed payer, payTo, asset, and amount. Use this method for reconciliation, dispute resolution, or automated billing checks.
string
Passed through to
list(). Limits the audit to receipts after the given consensus timestamp.string
When set, flags any receipt written by an HCS payer that is not this account ID. Catches receipts that were injected by a third party into the topic.
VerifiedReceipt Fields
Receipt
The original parsed receipt. See the Receipt fields reference below.
string
The HCS consensus timestamp of the receipt message.
number
The topic sequence number of the receipt message.
MirrorTransaction | null
The settlement transaction as returned by the mirror node, or
null if the transaction was not found. A null here means the transaction has not been indexed yet or the transactionId in the receipt is incorrect.boolean
true when the on-chain transfer fully matches the receipt: the correct asset was transferred, the right amount was credited to payTo, and the right amount was debited from payer. false if any check failed or the transaction was not found.string[]
A human-readable list of every discrepancy found during verification. An empty array means the receipt is clean. Possible entries include credit shortfall amounts, debit shortfall amounts, unexpected transaction results, and missing transactions.