npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

staxial-sdk

v0.2.1

Published

TypeScript SDK for interacting with Staxial Health contracts on the Stacks blockchain

Readme

staxial-sdk

TypeScript SDK for interacting with Staxial Health contracts on the Stacks blockchain.

Features

  • 🏥 Hospital Registry - Manage hospital registrations and verifications
  • 📋 Patient Records - Secure medical records with access control
  • 📅 Appointments - Book and manage appointments
  • 💊 Prescriptions - Issue and track prescriptions
  • 🔐 Type-safe - Full TypeScript support with comprehensive types
  • 🚀 Easy to use - Simple, intuitive API

Installation

npm install staxial-sdk

Quick start

import { 
  createStaxialConfig, 
  getHospital,
  getPatient,
  getAppointment 
} from 'staxial-sdk';

const config = createStaxialConfig({
  network: 'testnet',
  contractAddress: 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM',
});

// Get hospital information
const hospital = await getHospital(config, 1);
console.log(`Hospital: ${hospital?.name}`);

// Check patient registration
const patient = await getPatient(config, 'ST2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKNRV9EJ');
console.log(`Registered: ${patient?.registered}`);

// Get appointment details
const appointment = await getAppointment(config, 1);
console.log(`Status: ${appointment?.status}`);

API Reference

Configuration

const config = createStaxialConfig({
  network: 'mainnet' | 'testnet',
  contractAddress: 'SP...',
  contractName: 'staxial',  // optional
  stacksApiUrl: 'https://...', // optional
});

Hospital Registry

| Function | Description | |---|---| | getHospital(config, id) | Get hospital details by ID | | getHospitalByPrincipal(config, address) | Get hospital by owner address | | isHospitalVerified(config, id) | Check if hospital is verified | | getHospitalSpecialties(config, id) | Get all specialties for a hospital | | getMinStake(config) | Get minimum stake required |

Patient Records

| Function | Description | |---|---| | getPatient(config, address) | Get patient information | | isPatientRegistered(config, address) | Check if patient is registered | | getMedicalRecord(config, id) | Get medical record by ID | | getPatientRecords(config, address) | Get all records for a patient | | hasAccess(config, patient, hospital) | Check if hospital has access |

Appointments

| Function | Description | |---|---| | getAppointment(config, id) | Get appointment details | | getPatientAppointments(config, address) | Get all appointments for patient | | getHospitalAppointments(config, address) | Get all appointments for hospital | | getPlatformFee(config) | Get platform fee percentage |

Prescriptions

| Function | Description | |---|---| | getPrescription(config, id) | Get prescription details | | getMedication(config, prescriptionId, index) | Get medication details | | getPatientPrescriptions(config, address) | Get all prescriptions for patient | | getPharmacy(config, id) | Get pharmacy details | | isPrescriptionValid(config, id) | Check if prescription is valid |

Utilities

import { 
  microToStx, 
  stxToMicro, 
  truncateAddress, 
  formatStx, 
  formatDuration 
} from 'staxial-sdk';

microToStx(1_000_000);                // 1
stxToMicro(1);                        // 1000000n
truncateAddress('SP2J6Z...V9EJ', 6);  // 'SP2J6Z…RV9EJ'
formatStx(1_500_000);                 // '1.5 STX'
formatDuration(144);                  // '1 day'

Constants

import { 
  MS_PER_BLOCK, 
  BLOCKS_PER_DAY, 
  BLOCKS_PER_WEEK 
} from 'staxial-sdk';

| Constant | Value | Description | |---|---|---| | MS_PER_BLOCK | 600_000 | Milliseconds per Stacks block | | BLOCKS_PER_DAY | 144 | ~1 day | | BLOCKS_PER_WEEK | 1_008 | ~1 week | | BLOCKS_PER_MONTH | 4_320 | ~1 month | | BLOCKS_PER_YEAR | 52_560 | ~1 year |

Examples

Check Hospital Status

const hospital = await getHospital(config, 1);
if (hospital?.verified && hospital.status === 'active') {
  console.log(`${hospital.name} is verified and active`);
  console.log(`Rating: ${hospital.rating}/5`);
}

Get Patient Medical Records

const records = await getPatientRecords(config, patientAddress);
for (const record of records) {
  console.log(`${record.recordType}: ${record.description}`);
  console.log(`IPFS: ${record.ipfsHash}`);
}

Check Appointment Status

const appointment = await getAppointment(config, appointmentId);
console.log(`Patient: ${appointment?.patient}`);
console.log(`Hospital: ${appointment?.hospital}`);
console.log(`Status: ${appointment?.status}`);
console.log(`Fee: ${microToStx(appointment?.fee || 0n)} STX`);

TypeScript Support

The SDK is written in TypeScript and provides full type definitions:

import type { 
  Hospital, 
  Patient, 
  Appointment, 
  Prescription 
} from 'staxial-sdk';

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT