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

Payments

Parsing and validating payments

Reading a payment answers three separate questions: did it happen, did it execute, and is it the payment you were waiting for. The SDK keeps them separate so you never conflate them.

Parsing a transaction

TypeScript
const payments = await hive.payments.parse({ transactionId: id });

payments[0];
// {
//   network: "hive",
//   transactionId: "abc…",
//   operationIndex: 0,
//   success: null,          // parse never verifies execution
//   status: "pending",
//   transfer: { from: "alice", account: "bob", symbol: "HIVE", quantity: "10.000" },
//   trigger: { action: "purchase", metadata: { orderId: "A-1029" } },
// }

A transaction can carry several payments. A memo that is not valid standardized JSON is not an error: trigger is simply null. Read the returned network field to see which layer the payment came from — detection is automatic.

Validating expectations

TypeScript
const result = await hive.payments.validate({
  transactionId: id,
  expected: {
    from: "alice",
    account: "treasury-account",
    symbol: "HIVE",
    quantity: "10.000",
    action: "purchase",
  },
});

switch (result.status) {
  case "success":   return fulfil(result);
  case "invalid":   return reject(result.error);   // executed, wrong details
  case "failed":    return reject("execution failed");
  case "pending":   return retryLater();
  case "not_found": return reject("unknown transaction");
}
PaymentExpectation (all optional)
ParameterTypeRequiredDescription
fromstringNoExpected sender account.
accountstringNoExpected recipient account.
symbolstringNoExpected asset or token symbol.
quantitystringNoCompared numerically as digits — "100" equals "100.000".
actionstringNoExpected trigger action name.

The result shape

A validation result is a ParsedPayment with a verified status and a boolean success. For native payments, existence is success. For Hive Engine, the sidechain logs decide.

ParsedPayment
ParameterTypeRequiredDescription
network"hive" | "engine"NoDetected automatically — where the payment lives.
transactionIdstring | nullNoHive transaction id.
operationIndexnumberNoPosition inside the transaction.
successboolean | nullNonull when execution was not verified.
statusPaymentStatusNoLifecycle status.
transferPaymentTransferNofrom, account, symbol, quantity, memo.
triggerActionPayload | nullNoThe standardized action payload, when the memo carried one.
errorstring?NoWhy it is invalid or failed.

Idempotency

Note

The SDK is stateless. Store transactionId plus operationIndex as your delivery key, and check it before crediting anything — a stream restart will legally replay blocks you already processed.