HashAnchor Guide
API and SDK reference
The SDK is a thin client over the hosted HTTP API. Use either; they are the same calls.
SDK methods#
| Method | Auth | Purpose |
|---|---|---|
new HashAnchor({ apiKey?, baseUrl? }) | — | Create a client. Default deployment: https://hashanchor.xid.network. |
HashAnchor.provision(name) | none | Create a hosted-service API key. |
anchor(content) | key | Hash content and submit it. |
submitHash(hash) | key | Submit a precomputed 0x + 32-byte hash. |
submitBatch(items) | key | Submit up to 100 hashes at once. |
getStatus(hash) | key | Lifecycle state and anchor metadata. |
batchStatus(hashes) | key | Query many hashes in one call. |
getQuota() | key | Plan, quota and rate limits for your key. |
getReceipt(hash) | none | Portable receipt — 404 until anchored. |
verify(hash) | none | Ask the service to check the proof and anchor transaction. |
getChains() | none | Anchoring chains the deployment advertises. |
settle(envelope) | none | Relay x402 proofs; one result per proof. |
buildSettlePayload(proof, options) | offline | Reshape one proof, no network call. |
verifyReceiptProof(receipt) | offline | Verify an inclusion path locally. |
HTTP endpoints#
| Endpoint | Auth | Does |
|---|---|---|
POST /auth/provision | none | Self-serve a free API key |
POST /v1/hashes/anchor | key | Anchor raw content (text or base64) |
POST /v1/hashes | key | Submit a precomputed hash |
POST /v1/hashes/batch | key | Submit up to 100 hashes |
GET /v1/hashes/:hash | key | Full status, with batch and anchor once available |
POST /v1/hashes/status | key | Status for many hashes |
GET /v1/quota | key | Plan, monthly usage and rate limit |
GET /v1/verify/:hash | none | Check proof and on-chain anchor |
GET /v1/receipts/:hash | none | Portable JSON receipt |
GET /v1/chains | none | Supported anchoring chains |
POST /v1/x402/settle | none | Stateless x402 settlement relay |
Send the key as Authorization: Bearer ha_…. The public read endpoints allow cross-origin requests, so a web page can fetch and verify a receipt directly.
Errors and limits#
Non-2xx responses are JSON { "error": "…" }; the SDK throws them as HashAnchorError with .status and .body — except settle(), which returns results instead. Free-plan defaults are 100 requests per minute and 10,000 per day per key, with a monthly hash quota; call getQuota() for yours.
Installing#
npm install github:TLAY-IO/hashanchor#v1.0.1- Pin a tag, never a branch.
#mainmoves under you. - The package compiles itself on install through a
preparescript, so no build step is needed — but a Git dependency needsgitin the image, which slim bases such asnode:*-alpinelack. - Do not swap in a source tarball to avoid that: npm skips
preparefor tarballs, and the install succeeds but fails at runtime withERR_MODULE_NOT_FOUND.
Full details: API reference and getting started in the repository.