Skip to content
Integra Protocol
API

@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

PropertyTypeDescription
assetstring-
idDigest`0x${string}`hederaIdDigest of the payer.
networkHederaNetwork-
payeestringThe option's payTo.
settleBynumberUnix seconds: the time reference ran plus maxTimeoutSeconds.
transaction?stringThe facilitator's SettlementResponse.transaction, mirror form.

HederaBody

Properties

PropertyTypeDescription
bodyBytesUint8Array<ArrayBuffer>-
idHederaTxId-
maxFeestringtransactionFee: the most the fee payer pays, in tinybars, a decimal integer.
memostring-
nodestringnodeAccountID: the node the body is for.
transfer?HederaTransferThe body's cryptoTransfer; absent where the body is another transaction.
validDurationnumbertransactionValidDuration, in seconds.

HederaChannelConfig

Properties

PropertyType
authorizedSigner`0x${string}`
chainId295 | 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

PropertyTypeDescription
maxFeestring-
nodesreadonly string[]The node of each body the presented list holds; one for a single Transaction.
transferHederaTransfer-

HederaReader

Bounded, read-only calls against one network's Mirror Node. Every failure rejects.

Properties

PropertyModifierType
networkreadonlyHederaNetwork

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
ParameterType
q{ account: string; after: string; until: string; }
q.accountstring
q.afterstring
q.untilstring
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<readonly MirrorEntry[] | null>

GET /api/v1/transactions/{id}: the answer's transactions; null on the mirror's 404 for the id.

Parameters
ParameterType
mirrorIdstring
Returns

Promise<readonly MirrorEntry[] | null>


HederaRef

The read keys reference returns.

Properties

PropertyTypeDescription
expectMemostringThe body's memo: H's LCP string.
networkHederaNetwork-
payeestringThe option's payTo.
payerstringThe one account the signed body debits: the payer, the signer the read names, and the search's key.
presentedHederaPresentedThe rest of the members of the payment presented.
transactionIdstringThe transaction id, the single-use value, in the Mirror Node's form.
validDurationnumbertransactionValidDuration, in seconds.
validStartstringThe 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

PropertyTypeDescription
accountstring-
amountstringThe change in the asset's smallest unit, a decimal integer, negative for a debit.
isApprovalbooleanis_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

PropertyType
hbarreadonly HederaRow[]
tokensreadonly object[]

HederaTxId

Properties

PropertyTypeDescription
accountstring"shard.realm.num"
nanosnumberAn integer from 0 to 999,999,999.
secondsbigintA non-negative bigint.

HederaUnsigned

The body the payer signs, and how its signature completes the wire transaction.

Properties

PropertyType
requestobject
request.bodyBytesUint8Array<ArrayBuffer>
request.kind"hedera-body"

Methods

complete()

complete(s): string | Refusal

The signed Transaction, base64.

Parameters
ParameterType
s{ publicKey: Uint8Array; signature: Uint8Array; type: "ed25519" | "ecdsa-secp256k1"; }
s.publicKeyUint8Array
s.signatureUint8Array
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

PropertyType
domainobject
domain.chainId295 | 296
domain.name"Hedera Stream Channel"
domain.verifyingContract`0x${string}`
domain.version"1"
messageobject
message.channelId`0x${string}`
message.cumulativeAmountbigint
primaryType"Voucher"
typesobject
types.Voucher[{ name: "channelId"; type: "bytes32"; }, { name: "cumulativeAmount"; type: "uint128"; }]

MirrorEntry

The Mirror Node's Transaction entry: the fields read here.

Properties

PropertyTypeDescription
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?numberThe fee charged to the transaction's fee payer, in tinybars; its transfers row includes it.
consensus_timestampstring-
max_fee?string-
memo_base64string | null-
name?stringThe transaction's type: CRYPTOTRANSFER for a transfer.
node?string | nullThe node the transaction was submitted through.
noncenumber-
resultstring-
scheduledboolean-
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?stringThe 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

PropertyType
nextstring | null
transactionsreadonly MirrorEntry[]

MirrorRow

A transfer row of a Mirror Node entry: transfers, token_transfers (with token_id) or staking_reward_transfers.

Properties

PropertyType
accountstring
amountnumber
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

PropertyType
channelHex
escrowHex
networkHederaNetwork
phase"close"
searchobject
search.addressHex
search.topicsreadonly (Hex | null)[]
transactionHex

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

const CHANNEL_CLOSED_TOPIC: "0x92ed5fe0fe56b3f4185e688efb342e92a4492b9df29ad5de596c44e64d097b51" = "0x92ed5fe0fe56b3f4185e688efb342e92a4492b9df29ad5de596c44e64d097b51"

ChannelClosed(bytes32,address,address,uint256,uint256).


CHANNEL_OPENED_TOPIC

const CHANNEL_OPENED_TOPIC: "0xcd6e60364f8ee4c2b0d62afc07a1fb04fd267ce94693f93f8f85daaa099b5c94" = "0xcd6e60364f8ee4c2b0d62afc07a1fb04fd267ce94693f93f8f85daaa099b5c94"

ChannelOpened(bytes32,address,address,address,address,bytes32,uint256): channel, payer, payee indexed.


exactHedera

const exactHedera: 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: readonly PaymentRequirements[]; 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

const exactHederaExecutor: 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: readonly string[]; 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: readonly PaymentRequirements[]; 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: readonly HederaBody[]; }

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

ParameterType
wireUint8Array

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

ParameterType
refExecutorRef & object
readerHederaReader
queryHederaQuery<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

ParameterType
cHederaChannelConfig

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

ParameterType
payerstring

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

ParameterType
refHederaRef
readerHederaReader
queryHederaQuery<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

ParameterType
c{ chainId: 295 | 296; channelId: `0x${string}`; escrow: `0x${string}`; }
c.chainId295 | 296
c.channelId`0x${string}`
c.escrow`0x${string}`
cumulativebigint

Returns

HederaVoucherTypedData


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

ParameterType
idHederaTxId

Returns

string


txIdText()

txIdText(id): string

"0.0.1235@1700000000.000000000". Throws TypeError on an id that is not a HederaTxId.

Parameters

ParameterType
idHederaTxId

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

On this page