npm.io
0.1.0 • Published yesterday

hallmark-sdk

Licence
MIT
Version
0.1.0
Deps
1
Size
10 kB
Vulns
0
Weekly
0

hallmark-sdk

Receipt-aware TypeScript client for the Hallmark read layer on Solana.

Every read returns { result, slot, receipt }, where receipt is an ed25519 signature over a canonical digest of the request and response. verify() recomputes that digest and checks the signature against Hallmark's published key — offline, no network round-trip, no trust in the responder.

Install

npm install hallmark-sdk

Usage

import { HallmarkClient } from "hallmark-sdk";

const hallmark = new HallmarkClient({
  // baseUrl: "https://hallmarkgrid.xyz", // optional, this is the default
  // apiKey,                              // optional, free tier needs none
});

const { result, receipt } = await hallmark.getBalance(addr);
console.log(result.sol, "SOL @ slot", receipt.slot);

const check = await hallmark.verify({ result, slot: receipt.slot, receipt });
// { ok: true, digestMatches: true, signatureValid: true }

Methods

Method Returns
getBalance(address) { lamports, sol }
getAccountInfo(address) { owner, lamports, executable, rentEpoch, dataLen }
getSlot() { slot }
getTokenAccountsByOwner(owner) { count, accounts[] }
verify(signed) { ok, digestMatches, signatureValid, recomputedDigest }

Verifying manually

import { verifyReceipt, HALLMARK_PUBLIC_KEY } from "hallmark-sdk";

const v = await verifyReceipt(HALLMARK_PUBLIC_KEY, signedResponse);
if (!v.ok) throw new Error("do not trust this answer");

MIT

Keywords