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

Reading

Custom JSON parser

The parser is pure and dependency-free. It turns an operation's json string into a validated event, or reports precisely why it is not protocol-compliant.

Parsing

TypeScript
import { HiveClient } from "hivexph-sdk";

const hive = new HiveClient();

// Parse + validate a custom_json operation into a normalized event.
const result = hive.customJson.parse(operation, {
  blockNumber: 109_542_165,
  blockTimestamp: "2024-05-01T12:00:00",
  transactionId: "<trx-id>",
  transactionIndex: 0,
  operationIndex: 0,
}, { id: "my-application" });   // optional filter: { id, actions }

if (result.status === "ok") {
  result.event.action;   // "claim"
  result.event.metadata; // { rewardId: "123" }
} else if (result.status === "invalid") {
  result.reason;         // human-readable failure reason
} else {
  // "not_custom_json" — different id, filtered action, or not a custom_json op
}

Failure handling

The parser never throws on bad input. Malformed JSON, a missing action, or metadata that is not an object all resolve to an invalid result with a reason string.

Note

The reader collects these into invalid, and the block stream forwards them to onInvalidPayload, so a single bad operation never stops a run.