@healchain/sdk 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +45 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@healchain/sdk",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "JavaScript SDK for HealChain — self-healing decentralized storage via Reed-Solomon erasure coding",
5
5
  "main": "src/index.js",
6
6
  "module": "src/index.js",
package/src/index.js CHANGED
@@ -272,6 +272,51 @@ class HealChain {
272
272
  async list(page = 0, limit = 10) {
273
273
  return this._fetch(`/listRecords?page=${page}&limit=${limit}`);
274
274
  }
275
+
276
+ // ── getBillingBalance() ───────────────────────────────────────────────────
277
+ /**
278
+ * Get credit balances for a wallet address. No API key required.
279
+ *
280
+ * @param {string} walletAddress - Wallet address (0x...)
281
+ * @returns {Promise<object>} Production and testnet balances
282
+ */
283
+ async getBillingBalance(walletAddress) {
284
+ const path = `/billing/balance?wallet=${encodeURIComponent(walletAddress)}`;
285
+ return this._fetch(path, { headers: { 'User-Agent': 'healchain-sdk/0.3.0' } });
286
+ }
287
+
288
+ // ── createCheckout() ──────────────────────────────────────────────────────
289
+
290
+ /**
291
+ * Create a Stripe Checkout session for topping up credits.
292
+ * Redirects user to Stripe hosted payment page.
293
+ *
294
+ * @param {string} walletAddress - Wallet address to credit
295
+ * @param {number} amountCents - Amount in cents (min 500 = $5.00)
296
+ * @returns {Promise<object>} { checkout_url, session_id, amount_usd }
297
+ */
298
+ async createCheckout(walletAddress, amountCents) {
299
+ return this._fetch('/checkout/create', {
300
+ method: 'POST',
301
+ body: JSON.stringify({ wallet_address: walletAddress, amount_cents: amountCents }),
302
+ });
303
+ }
304
+
305
+ // ── requestTestnetCredits() ───────────────────────────────────────────────
306
+
307
+ /**
308
+ * Request free testnet credits ($1.00 per wallet per 24 hours).
309
+ * Wallet must be whitelisted during early access phase.
310
+ *
311
+ * @param {string} walletAddress - Wallet address to credit
312
+ * @returns {Promise<object>} { granted_usd, balance_usd, expires_in_days }
313
+ */
314
+ async requestTestnetCredits(walletAddress) {
315
+ return this._fetch('/testnet/requestCredits', {
316
+ method: 'POST',
317
+ body: JSON.stringify({ wallet_address: walletAddress }),
318
+ });
319
+ }
275
320
  }
276
321
 
277
322
  // ── Exports ───────────────────────────────────────────────────────────────────