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 🙏

© 2025 – Pkg Stats / Ryan Hefner

aptick-sdk

v0.1.0

Published

Official SDK for Aptick - Decentralized Billing System on Aptos

Readme

aptick-sdk

NOTE:This is For Testing purpose Only

This Is The official JavaScript/TypeScript SDK for Aptick - a decentralized billing system built on the Aptos blockchain.

Features

  • 🏗️ Type-safe - Full TypeScript support with comprehensive type definitions
  • 🔗 Multi-wallet - Works with all Aptos wallet adapters
  • Easy to use - Simple, intuitive API design
  • 🛡️ Error handling - Comprehensive error handling with meaningful messages
  • ⚛️ React ready - Built-in React hooks and components
  • 🌐 Multi-network - Support for mainnet, testnet, devnet, and local networks

Installation

npm install aptick-sdk
# or
yarn add aptick-sdk
# or
pnpm add aptick-sdk

Quick Start

For Users

import { createAptickClient, AptickConfig } from 'aptick-sdk';

const config: AptickConfig = {
  network: 'devnet', // or 'mainnet', 'testnet', 'local'
  contractAddress: '0x123...', // Optional: defaults to official deployed contracts
};

const client = createAptickClient(config);
await client.initialize();

For Providers (After Registration)

Once you've registered on the Aptick platform and received your billing ID:

  1. Install the SDK: npm install aptick-sdk
  2. Follow the Integration Guide
  3. Use the Provider Checklist
  4. Check Examples for your use case

React Integration

import { AptickProvider, useAptick, setupAptick } from 'aptick-sdk';
import { useWallet } from '@aptos-labs/wallet-adapter-react';

// Setup the client
const client = await setupAptick({ network: 'devnet' });

// Wrap your app
function App() {
  return (
    <AptickProvider client={client}>
      <YourComponents />
    </AptickProvider>
  );
}

// Use in components
function ProviderRegistration() {
  const client = useAptick();
  const { signAndSubmitTransaction } = useWallet();

  const handleRegister = async () => {
    const result = await client.registerProvider(
      signAndSubmitTransaction,
      0.001, // 0.001 APT per unit
      'GB'   // Unit type
    );

    if (result.success) {
      console.log('Registered with billing ID:', result.data);
    }
  };

  return <button onClick={handleRegister}>Register as Provider</button>;
}

API Reference

Core Classes

AptickClient

The main client for interacting with the Aptick billing system.

// Initialize
const client = new AptickClient(config);
await client.initialize();

// Register as provider
const result = await client.registerProvider(walletSignFn, pricePerUnit, unit);

// Deposit APT
await client.deposit(walletSignFn, billingId, aptAmount);

// Record usage (providers only)
await client.recordUsage(walletSignFn, billingId, userAddress, units);

// Terminate service and get refund
await client.terminateService(walletSignFn, billingId);

// Query data
const provider = await client.getProvider(billingId);
const escrow = await client.getUserEscrow(billingId, userAddress);
const balance = await client.getAptBalance(address);

AptickUtils

Utility functions for common operations.

import { AptickUtils } from 'aptick-sdk';

// Convert between APT and octas
const octas = AptickUtils.aptToOctas(1.5); // 150,000,000 octas
const apt = AptickUtils.octasToApt(150000000n); // 1.5

// Format for display
const formatted = AptickUtils.formatApt(150000000n); // "1.5000 APT"

// Validate addresses
const isValid = AptickUtils.isValidAddress('0x123...');

// Calculate costs
const cost = AptickUtils.calculateCost(10n, 1000n); // 10 units × 1000 octas = 10000 octas

React Hooks

useProviderRegistration

import { useProviderRegistration } from 'aptick-sdk';

const { registerProvider } = useProviderRegistration(client);

await registerProvider(signAndSubmitTransaction, 0.001, 'GB');

useUserOperations

import { useUserOperations } from 'aptick-sdk';

const { deposit, terminateService } = useUserOperations(client);

await deposit(signAndSubmitTransaction, billingId, 1.0);
await terminateService(signAndSubmitTransaction, billingId);

useProviderOperations

import { useProviderOperations } from 'aptick-sdk';

const { recordUsage } = useProviderOperations(client);

await recordUsage(signAndSubmitTransaction, billingId, userAddress, 10);

useAptickQuery

import { useAptickQuery } from 'aptick-sdk';

const { getProvider, getUserEscrow, getAptBalance } = useAptickQuery(client);

const provider = await getProvider(billingId);
const escrow = await getUserEscrow(billingId, userAddress);
const balance = await getAptBalance(address);

Examples

Complete Provider Registration Flow

import { createAptickClient, AptickUtils } from 'aptick-sdk';
import { useWallet } from '@aptos-labs/wallet-adapter-react';

async function registerAsProvider() {
  const client = createAptickClient({ network: 'devnet' });
  await client.initialize();
  
  const { signAndSubmitTransaction } = useWallet();
  
  // Validate inputs
  const validation = AptickUtils.validateBillingParams(0.001, 'GB');
  if (!validation.valid) {
    throw new Error(validation.error);
  }
  
  // Register
  const result = await client.registerProvider(
    signAndSubmitTransaction,
    0.001, // 0.001 APT per GB
    'GB'   // Gigabyte
  );
  
  if (result.success) {
    console.log(`Registered! Billing ID: ${result.data}`);
    console.log(`Transaction: ${result.transactionHash}`);
  } else {
    console.error(`Registration failed: ${result.error}`);
  }
}

User Deposit and Usage Flow

async function userFlow() {
  const client = createAptickClient({ network: 'devnet' });
  await client.initialize();
  
  const { signAndSubmitTransaction } = useWallet();
  const billingId = 1;
  const userAddress = '0x123...';
  
  // Check balance before
  const beforeBalance = await client.getAptBalance(userAddress);
  console.log(`Balance: ${AptickUtils.formatApt(beforeBalance.data!)}`);
  
  // Deposit 1 APT
  await client.deposit(signAndSubmitTransaction, billingId, 1.0);
  
  // Check escrow
  const escrow = await client.getUserEscrow(billingId, userAddress);
  console.log(`Escrow: ${AptickUtils.formatApt(escrow.data!.balance)}`);
  
  // Provider records usage (10 GB)
  // This would be called by the provider
  await client.recordUsage(signAndSubmitTransaction, billingId, userAddress, 10);
  
  // Terminate and get refund
  await client.terminateService(signAndSubmitTransaction, billingId);
}

Error Handling

All SDK methods return AptickResult<T> objects:

interface AptickResult<T> {
  success: boolean;
  data?: T;
  error?: string;
  transactionHash?: string;
}

// Always check success
const result = await client.registerProvider(/* ... */);
if (result.success) {
  console.log('Success:', result.data);
} else {
  console.error('Error:', result.error);
}

Configuration

Network Configuration

const config: AptickConfig = {
  network: 'devnet',
  contractAddress: '0x123...', // Optional
  moduleAccount: 'billing',    // Optional
  rpcUrl: 'https://...',      // Optional
};

Transaction Options

const options: TransactionOptions = {
  maxGasAmount: 10000,
  gasUnitPrice: 100,
  timeoutSecs: 30,
};

await client.registerProvider(walletSignFn, pricePerUnit, unit, options);

Contributing

See CONTRIBUTING.md for details.

License

MIT License - see LICENSE for details.