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#

MethodAuthPurpose
new HashAnchor({ apiKey?, baseUrl? })—Create a client. Default deployment: https://hashanchor.xid.network.
HashAnchor.provision(name)noneCreate a hosted-service API key.
anchor(content)keyHash content and submit it.
submitHash(hash)keySubmit a precomputed 0x + 32-byte hash.
submitBatch(items)keySubmit up to 100 hashes at once.
getStatus(hash)keyLifecycle state and anchor metadata.
batchStatus(hashes)keyQuery many hashes in one call.
getQuota()keyPlan, quota and rate limits for your key.
getReceipt(hash)nonePortable receipt — 404 until anchored.
verify(hash)noneAsk the service to check the proof and anchor transaction.
getChains()noneAnchoring chains the deployment advertises.
settle(envelope)noneRelay x402 proofs; one result per proof.
buildSettlePayload(proof, options)offlineReshape one proof, no network call.
verifyReceiptProof(receipt)offlineVerify an inclusion path locally.

HTTP endpoints#

EndpointAuthDoes
POST /auth/provisionnoneSelf-serve a free API key
POST /v1/hashes/anchorkeyAnchor raw content (text or base64)
POST /v1/hasheskeySubmit a precomputed hash
POST /v1/hashes/batchkeySubmit up to 100 hashes
GET /v1/hashes/:hashkeyFull status, with batch and anchor once available
POST /v1/hashes/statuskeyStatus for many hashes
GET /v1/quotakeyPlan, monthly usage and rate limit
GET /v1/verify/:hashnoneCheck proof and on-chain anchor
GET /v1/receipts/:hashnonePortable JSON receipt
GET /v1/chainsnoneSupported anchoring chains
POST /v1/x402/settlenoneStateless 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#

bash
npm install github:TLAY-IO/hashanchor#v1.0.1
  • Pin a tag, never a branch. #main moves under you.
  • The package compiles itself on install through a prepare script, so no build step is needed — but a Git dependency needs git in the image, which slim bases such as node:*-alpine lack.
  • Do not swap in a source tarball to avoid that: npm skips prepare for tarballs, and the install succeeds but fails at runtime with ERR_MODULE_NOT_FOUND.

Full details: API reference and getting started in the repository.