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

Reading

Transaction reader

After broadcasting, confirm what actually landed on chain. The reader fetches a transaction, locates its custom_json operations and decodes them into typed events.

Read a transaction

Read by id

TypeScript
const read = await hive.reader.transaction({
  transactionId: "b1e2...",
  id: "my-application",     // optional custom_json id filter
  actions: ["claim"],       // optional standardized action filter
});

// every operation, in blockchain order
for (const operation of read.operations) {
  console.log(operation.operationIndex, operation.kind, operation.operationType);
}

// derived views
read.customJson;  // standardized Custom JSON events
read.payments;    // native + Layer 2 payments, triggers already associated
read.nfts;        // Hive Engine NFT actions

Operations that match the id filter but break the payload protocol are never thrown — they land in invalid with a reason, so one malformed transaction cannot break a batch. Operations the SDK does not interpret are reported as kind: "unknown" instead of being dropped.

Result shape

TransactionResult
ParameterTypeRequiredDescription
transactionIdstringNoThe transaction that was read.
blockNumbernumberNoBlock containing the transaction.
blockTimestampstringNoBlock timestamp in ISO form.
transactionIndexnumber | nullNoPosition of the transaction inside its block.
operationsTransactionOperationResult<T>[]NoEvery operation in blockchain order, tagged custom_json / payment / nft / unknown.
customJsonCustomJsonEvent<T>[]NoDecoded, protocol-valid Custom JSON events.
paymentsParsedPayment<T>[]NoPayments with triggers associated. Layer 2 stays pending until verified.
nftsNormalizedNftOperation[]NoHive Engine NFT issue / transfer / burn actions.
invalid{ reason, raw }[]NoMatching operations that failed validation.
rawunknownNoUntouched RPC response.

Run a live stream

Reading by id is a one-shot lookup. To keep watching the chain, use the same reader in streaming mode — one block loop shared by every filter you register.

TypeScript
// multi-filter dispatcher over the single block stream
const stream = hive.reader.stream({ fromBlock: 90_000_000 });

stream.customJson({
  id: "my-application",
  actions: ["claim"],
  handler: (event) => console.log(event.blockNumber, event.action, event.metadata),
});

stream.payment({
  account: "my-shop",
  handler: (payment) => fulfilOrder(payment.trigger?.metadata),
  onFailed: (payment) => console.warn(payment.error),
});

await stream.start();   // starts reading blocks
stream.stop();          // ends the loop

Prefer async iteration? The same engine is exposed as iterators: hive.blocks.watch(), hive.customJson.watch() and hive.payments.watch().

TypeScript
const controller = new AbortController();

for await (const event of hive.customJson.watch({
  id: "my-application",
  actions: ["claim"],
  signal: controller.signal,
})) {
  console.log(event.blockNumber, event.action, event.metadata);
}