@integraledger/lcp/hedera
Hedera: the x402 pairings `x402/exact/hedera` (the ATR hash as the signed body memo) and `x402/exact/hedera/transfer-executor` (the hash advertised in the challenge only), with the transaction wire form and the Mirror Node settlement read.
For AI agents: this page as Markdown, and llms.txt, the index of every page.
Hedera: the x402 pairings x402/exact/hedera (the ATR hash as the signed body memo) and
x402/exact/hedera/transfer-executor (the hash advertised in the challenge only), with the transaction wire form and
the Mirror Node settlement read.
The wire form is read and written by hand (protobuf, five messages). The entry point also holds the escrow channel
pieces hederaChannelId and hederaVoucher, and FETCHED, the key under which a pairing's fetchPresented writes
the seller's read onto a credential.
Interfaces
ExecutorRef
Properties
| Property | Type | Description |
|---|---|---|
asset | string | - |
idDigest | `0x${string}` | hederaIdDigest of the payer. |
network | HederaNetwork | - |
payee | string | The option's payTo. |
settleBy | number | Unix seconds: the time reference ran plus maxTimeoutSeconds. |
transaction? | string | The facilitator's SettlementResponse.transaction, mirror form. |
HederaBody
Properties
| Property | Type | Description |
|---|---|---|
bodyBytes | Uint8Array<ArrayBuffer> | - |
id | HederaTxId | - |
maxFee | string | transactionFee: the most the fee payer pays, in tinybars, a decimal integer. |
memo | string | - |
node | string | nodeAccountID: the node the body is for. |
transfer? | HederaTransfer | The body's cryptoTransfer; absent where the body is another transaction. |
validDuration | number | transactionValidDuration, in seconds. |
HederaChannelConfig
Properties
| Property | Type |
|---|---|
authorizedSigner | `0x${string}` |
chainId | 295 | 296 |
escrow | `0x${string}` |
payee | `0x${string}` |
payer | `0x${string}` |
salt | `0x${string}` |
token | `0x${string}` |
HederaPresented
The members of the body the payer signed that the read compares with the landed entry, as presented.
Properties
| Property | Type | Description |
|---|---|---|
maxFee | string | - |
nodes | readonly string[] | The node of each body the presented list holds; one for a single Transaction. |
transfer | HederaTransfer | - |
HederaReader
Bounded, read-only calls against one network's Mirror Node. Every failure rejects.
Properties
| Property | Modifier | Type |
|---|---|---|
network | readonly | HederaNetwork |
Methods
accountTransactions()
accountTransactions(
q):Promise<MirrorPage>
One page of an account's transactions, oldest first: GET /api/v1/transactions with account.id the account,
timestamp gt: after and lte: until, order asc and limit 100.
Parameters
| Parameter | Type |
|---|---|
q | { account: string; after: string; until: string; } |
q.account | string |
q.after | string |
q.until | string |
Returns
Promise<MirrorPage>
latest()
latest():
Promise<string>
The mirror's latest consensus timestamp: the end of its newest block, timestamp.to of
GET /api/v1/blocks?order=desc&limit=1.
Returns
Promise<string>
oldest()
oldest():
Promise<string>
How far back the mirror holds records: the start of its oldest block, timestamp.from of
GET /api/v1/blocks?order=asc&limit=1, or archival where the endpoint is declared archival.
Returns
Promise<string>
transactions()
transactions(
mirrorId):Promise<readonlyMirrorEntry[] |null>
GET /api/v1/transactions/{id}: the answer's transactions; null on the mirror's 404 for the id.
Parameters
| Parameter | Type |
|---|---|
mirrorId | string |
Returns
Promise<readonly MirrorEntry[] | null>
HederaRef
The read keys reference returns.
Properties
| Property | Type | Description |
|---|---|---|
expectMemo | string | The body's memo: H's LCP string. |
network | HederaNetwork | - |
payee | string | The option's payTo. |
payer | string | The one account the signed body debits: the payer, the signer the read names, and the search's key. |
presented | HederaPresented | The rest of the members of the payment presented. |
transactionId | string | The transaction id, the single-use value, in the Mirror Node's form. |
validDuration | number | transactionValidDuration, in seconds. |
validStart | string | The valid start the id names, as a consensus timestamp seconds.nanos, nanoseconds in nine digits. |
HederaRow
One row of a transfer list, as the signed body or the mirror holds it: the account and its signed change.
Properties
| Property | Type | Description |
|---|---|---|
account | string | - |
amount | string | The change in the asset's smallest unit, a decimal integer, negative for a debit. |
isApproval | boolean | is_approval: true where the row spends an allowance the account granted, so the account did not sign it. |
HederaTransfer
A crypto transfer as the signed body holds it: its HBAR rows, and its rows per token.
Properties
| Property | Type |
|---|---|
hbar | readonly HederaRow[] |
tokens | readonly object[] |
HederaTxId
Properties
| Property | Type | Description |
|---|---|---|
account | string | "shard.realm.num" |
nanos | number | An integer from 0 to 999,999,999. |
seconds | bigint | A non-negative bigint. |
HederaUnsigned
The body the payer signs, and how its signature completes the wire transaction.
Properties
| Property | Type |
|---|---|
request | object |
request.bodyBytes | Uint8Array<ArrayBuffer> |
request.kind | "hedera-body" |
Methods
complete()
complete(
s):string|Refusal
The signed Transaction, base64.
Parameters
| Parameter | Type |
|---|---|
s | { publicKey: Uint8Array; signature: Uint8Array; type: "ed25519" | "ecdsa-secp256k1"; } |
s.publicKey | Uint8Array |
s.signature | Uint8Array |
s.type | "ed25519" | "ecdsa-secp256k1" |
Returns
string | Refusal
HederaVoucherTypedData
The EIP-712 voucher a Hedera session's payer signs: Voucher(bytes32 channelId,uint128 cumulativeAmount).
Properties
| Property | Type |
|---|---|
domain | object |
domain.chainId | 295 | 296 |
domain.name | "Hedera Stream Channel" |
domain.verifyingContract | `0x${string}` |
domain.version | "1" |
message | object |
message.channelId | `0x${string}` |
message.cumulativeAmount | bigint |
primaryType | "Voucher" |
types | object |
types.Voucher | [{ name: "channelId"; type: "bytes32"; }, { name: "cumulativeAmount"; type: "uint128"; }] |
MirrorEntry
The Mirror Node's Transaction entry: the fields read here.
Properties
| Property | Type | Description |
|---|---|---|
assessed_custom_fees? | readonly unknown[] | The custom fees a token transfer assessed (the detail of GET /api/v1/transactions/{id}); they change its rows. |
charged_tx_fee? | number | The fee charged to the transaction's fee payer, in tinybars; its transfers row includes it. |
consensus_timestamp | string | - |
max_fee? | string | - |
memo_base64 | string | null | - |
name? | string | The transaction's type: CRYPTOTRANSFER for a transfer. |
node? | string | null | The node the transaction was submitted through. |
nonce | number | - |
result | string | - |
scheduled | boolean | - |
staking_reward_transfers? | readonly MirrorRow[] | HIP-406 staking rewards paid by this transaction, in tinybars. transfers already holds each account's total change, so a reward is in the rewarded account's credit there, and the staking reward account 0.0.800 pays it. |
token_transfers? | readonly MirrorRow[] | - |
transaction_id? | string | The transaction id, shard.realm.num-seconds-nanos. |
transfers? | readonly MirrorRow[] | - |
valid_duration_seconds? | string | - |
valid_start_timestamp? | string | - |
MirrorPage
One page of the account's transactions: the answer's transactions and its links.next.
Properties
| Property | Type |
|---|---|
next | string | null |
transactions | readonly MirrorEntry[] |
MirrorRow
A transfer row of a Mirror Node entry: transfers, token_transfers (with token_id) or staking_reward_transfers.
Properties
| Property | Type |
|---|---|
account | string |
amount | number |
is_approval? | boolean |
token_id? | string |
Type Aliases
HederaCloseRef
HederaCloseRef =
object
A close: the transaction whose ChannelClosed log from the escrow names the channel, and search, the log filter
that finds that transaction when no one reports it.
Properties
| Property | Type |
|---|---|
channel | Hex |
escrow | Hex |
network | HederaNetwork |
phase | "close" |
search | object |
search.address | Hex |
search.topics | readonly (Hex | null)[] |
transaction | Hex |
HederaNetwork
HederaNetwork =
"hedera:mainnet"|"hedera:testnet"|"hedera:previewnet"|"hedera:devnet"
HederaQuery
HederaQuery<
Ref> =StatusQuery<Ref,string,"consensus",string>
Type Parameters
| Type Parameter |
|---|
Ref |
HederaStatus
HederaStatus =
StatusAnswer<string,"consensus",string>
The answer of hederaStatus and executorStatus: positions are the Mirror Node's consensus_timestamp
(seconds.nanos), and the one mark is consensus, the record the Mirror Node serves, which is final. A settled
answer of hederaStatus states presented (the profile x402/exact/hedera, rule 12).
Variables
CHANNEL_CLOSED_TOPIC
constCHANNEL_CLOSED_TOPIC:"0x92ed5fe0fe56b3f4185e688efb342e92a4492b9df29ad5de596c44e64d097b51"="0x92ed5fe0fe56b3f4185e688efb342e92a4492b9df29ad5de596c44e64d097b51"
ChannelClosed(bytes32,address,address,uint256,uint256).
CHANNEL_OPENED_TOPIC
constCHANNEL_OPENED_TOPIC:"0xcd6e60364f8ee4c2b0d62afc07a1fb04fd267ce94693f93f8f85daaa099b5c94"="0xcd6e60364f8ee4c2b0d62afc07a1fb04fd267ce94693f93f8f85daaa099b5c94"
ChannelOpened(bytes32,address,address,address,address,bytes32,uint256): channel, payer, payee indexed.
exactHedera
constexactHedera:Readonly<{advertise: (doc,h,link,offer,agreementUrl?) =>Refusal|PaymentRequired;bound: (presented) =>Promise<Refusal|`0x${string}`>;broadcaster: (presented) =>Promise<Refusal|Broadcaster>;build: (c,h) =>Promise<Refusal|HederaUnsigned>;claims:boolean;data:PairingData;id:"x402/exact/hedera";pattern:LcpPattern;read: (doc) =>Refusal|X402Read;recover: (input,reader) =>Promise<Refusal|`0x${string}`>;reference: (presented,option) =>Promise<Refusal|HederaRef>;status: (ref,reader,query) =>Promise<HederaStatus>;tie: (accepts,request) => ["x402", {accepts: readonlyPaymentRequirements[];request:RequestCommitment|ToolCallCommitment; }];unplaced: (option) =>Refusal|PaymentRequirements; }>
x402/exact/hedera. The payee broadcasts (broadcaster answers "payee"): the seller's facilitator, the
transaction's fee payer, adds its signature to the transaction the payer signed and submits it; status reads it by
its transaction id.
exactHederaExecutor
constexactHederaExecutor:Readonly<{advertise: (doc,h,link,offer,agreementUrl?) =>Refusal|PaymentRequired;bound: (presented) =>Promise<Refusal|`0x${string}`>;broadcaster: (presented) =>Promise<Refusal|Broadcaster>;build: (c,h) =>Promise<Refusal| {request: {amount:string;asset:string;executors: readonlystring[];kind:"hedera-executor";network:HederaNetwork;payTo:string;validBefore:number; };complete:Refusal|ExecutorPaymentPayload; }>;claims:boolean;data:PairingData;id:"x402/exact/hedera/transfer-executor";pattern:LcpPattern;read: (doc) =>Refusal|X402Read;reference: (presented,option) =>Promise<Refusal|ExecutorRef>;status: (ref,reader,query) =>Promise<HederaStatus>;tie: (accepts,request) => ["x402", {accepts: readonlyPaymentRequirements[];request:RequestCommitment|ToolCallCommitment; }];unplaced: (option) =>Refusal|PaymentRequirements; }>
x402/exact/hedera/transfer-executor. The payee broadcasts (broadcaster answers "payee"): the seller's
facilitator submits the executor's transfer under the authorization the payer signed, and names its transaction;
status reads it.
Functions
decodeHederaTx()
decodeHederaTx(
wire):Refusal| {bodies: readonlyHederaBody[]; }
Reads a wire Transaction, or the SDK's TransactionList of them (a top-level field 1): each body's transaction
id, node, maximum fee, valid duration, memo, crypto transfer and exact bytes, the bytes a copy of wire's. Every
body of a list must equal the first in all but its node, else hedera/list-inconsistent; a valid duration above
the chain's 180 seconds is hedera/valid-duration.
Parameters
| Parameter | Type |
|---|---|
wire | Uint8Array |
Returns
Refusal | { bodies: readonly HederaBody[]; }
executorStatus()
executorStatus(
ref,reader,query):Promise<HederaStatus>
The read of the executor's transfer by the transaction the facilitator named, as the profile read-status answers
it at coverage none (the profile x402/exact/hedera, rule 15): the named transaction is the act, read in its
merged consensus record, the user entry and its child entries, each account's net change in every asset taken with
HIP-406 staking rewards taken back out and the user entry's charged_tx_fee added back to the fee payer. Its signer
is the one account the record debits, which is the payer where its digest is the one reference recorded and the
option's payee where it is that account; it pays where it credits the payee. The named transaction id is single-use:
an entry under it that decides consumed it, and with none it lapses once its valid start plus the chain's longest
valid duration, 180 seconds, is strictly before the mirror's latest consensus timestamp, read first, the mirror
holding records back to that valid start; no search is made, the act being the transaction named. A ref whose
transaction is not a Mirror Node transaction id, whose asset is not shard.realm.num (it is read for nothing
else), or whose idDigest is not 0x and 64 hex digits, is
unparseable, with nothing read; a record whose rows are not well formed is unparseable, and more than 64 entries
too-large.
Parameters
| Parameter | Type |
|---|---|
ref | ExecutorRef & object |
reader | HederaReader |
query | HederaQuery<ExecutorRef & object> |
Returns
Promise<HederaStatus>
hederaChannelId()
hederaChannelId(
c):`0x${string}`
keccak256(abi.encode(payer, payee, token, salt, authorizedSigner, escrow, chainId)), lowercase. Throws TypeError
when an address is not 0x and 40 hex digits, the salt is not a 32-byte hash, or the chain id is not 295 or 296.
Parameters
| Parameter | Type |
|---|---|
c | HederaChannelConfig |
Returns
`0x${string}`
hederaIdDigest()
hederaIdDigest(
payer):Promise<`0x${string}`>
The core's hash over the ASCII of payer: the payer's identity, never shown in the clear.
Parameters
| Parameter | Type |
|---|---|
payer | string |
Returns
Promise<`0x${string}`>
hederaStatus()
hederaStatus(
ref,reader,query):Promise<HederaStatus>
The read of the act the query asks about (the profiles read-status and x402/exact/hedera). The mirror's latest
consensus timestamp is read first, then the entries under the presented transaction id, its single-use value. An
entry under the id that decides consumed the id: it is the act where it succeeded, its memo is H's string, it is the
payer's own transfer and, for the act payment, it credits the option's payee; a failed result under the id is the
act's own failed result. With no such entry the id is unconsumed, live while the mirror holds records back to the
valid start (else history-gap), and lapsed once the valid start plus the valid duration is strictly before the
timestamp read first. Before a
failed, the search for H over the payer's transactions, from the position the caller gives, or the search position
an earlier answer returned, to that timestamp; an act it finds is the act, and with none found the answer is
pending, search-incomplete, at the search's position, the search proving no absence until a run shows its three
facts. A settled answer states presented.
Parameters
| Parameter | Type |
|---|---|
ref | HederaRef |
reader | HederaReader |
query | HederaQuery<HederaRef> |
Returns
Promise<HederaStatus>
hederaVoucher()
hederaVoucher(
c,cumulative):HederaVoucherTypedData
The voucher for cumulative on a channel, under the escrow's domain. Throws TypeError when the channel id is not a
32-byte hash, the escrow not 0x and 40 hex digits, the chain id not 295 or 296, or cumulative not a bigint that
fits a uint128.
Parameters
| Parameter | Type |
|---|---|
c | { chainId: 295 | 296; channelId: `0x${string}`; escrow: `0x${string}`; } |
c.chainId | 295 | 296 |
c.channelId | `0x${string}` |
c.escrow | `0x${string}` |
cumulative | bigint |
Returns
txIdMirror()
txIdMirror(
id):string
"0.0.1235-1700000000-000000000", the Mirror Node's form. Throws TypeError on an id that is not a HederaTxId.
Parameters
| Parameter | Type |
|---|---|
id | HederaTxId |
Returns
string
txIdText()
txIdText(
id):string
"0.0.1235@1700000000.000000000". Throws TypeError on an id that is not a HederaTxId.
Parameters
| Parameter | Type |
|---|---|
id | HederaTxId |
Returns
string
References
Broadcaster
Re-exports Broadcaster
ExecutorPayload
Re-exports ExecutorPayload
ExecutorPaymentPayload
Re-exports ExecutorPaymentPayload
FETCHED
Re-exports FETCHED
X402Payment
Re-exports X402Payment
X402Read
Re-exports X402Read
Last updated on
@integraledger/lcp/evm
eip155 rail pieces: EIP-3009 and Permit2 typed data, the settlement read from a token's events, the read of a signed pull authorization's use, ERC-7710 permission contexts, the commerce-payments escrow's pieces, and x402's Permit2 proxy addresses.
@integraledger/lcp/lightning
BOLT11 invoices and the Lightning pairings: on x402 (`x402/exact/lnbtc/payment-hash`) the ATR commits the option's `extra.paymentHash`, and on MPP the seller's node writes the ATR hash as the invoice's description hash `h`.