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

@coinrailz/iot-payments

v1.1.0

Published

IoT Payments SDK - Device-to-device payments, metering, and credits for IoT devices and DePIN networks

Readme

@coinrailz/iot-payments

IoT Payments SDK for device-to-device payments, metering, and credits. Built for IoT devices, DePIN networks, and machine-to-machine commerce.

Features

  • Device Registration - Register IoT devices with unique IDs and wallet addresses
  • Credits System - Pre-purchase credits for pay-per-event billing
  • D2D Transfers - Device-to-device payments with 2% + $0.02 fee
  • Metering - Track billable events (messages, sensor readings, API calls)
  • Multi-chain - Support for Base, Ethereum, Polygon, Arbitrum, Solana
  • Non-custodial - Devices control their own wallets
  • Secure Auth - SHA-256 hashed API keys with rotation support

Installation

npm install @coinrailz/iot-payments

Quick Start

import { CoinRailzIoT } from '@coinrailz/iot-payments';

// Step 1: Create an account (no API key needed for initial creation)
const iot = new CoinRailzIoT({
  baseUrl: 'https://coinrailz.com'
});

const { account, apiKey } = await iot.createAccount({
  accountName: 'My Sensor Fleet'
});

// IMPORTANT: Store the apiKey securely - it cannot be retrieved again!
console.log('API Key:', apiKey);

// Step 2: Use the API key for all subsequent requests
const authenticatedClient = new CoinRailzIoT({
  apiKey: apiKey,
  baseUrl: 'https://coinrailz.com'
});

// Register a device
const { device } = await authenticatedClient.registerDevice({
  deviceId: 'sensor-001',
  accountId: account.id,
  deviceType: 'sensor'
});

// Check balance
const balance = await authenticatedClient.getBalance('sensor-001');
console.log(`Balance: ${balance.balanceFormatted}`);

// Charge for a message (1 credit = $0.01)
await authenticatedClient.chargePerMessage('sensor-001', 'temperature/readings');

// D2D transfer (minimum $0.05)
const { transfer } = await authenticatedClient.transfer({
  fromDeviceId: 'sensor-001',
  toDeviceId: 'gateway-001',
  amount: 0.50
});
console.log(`Transferred: $${transfer.netAmount} (fee: $${transfer.fee})`);

API Key Security

API keys are generated when you create an account and are only shown once. Store them securely.

// Create account - returns one-time API key
const { account, apiKey, apiKeyWarning } = await iot.createAccount({
  accountName: 'Production Fleet'
});
// apiKeyWarning: "Store this API key securely. It cannot be retrieved again."

// Rotate API key (invalidates the old key immediately)
const { apiKey: newApiKey } = await iot.rotateApiKey(account.id);

Credits Packs (v1.1 - 2x More Credits!)

| Pack | Price | Credits | Per Credit | Discount | |------|-------|---------|------------|----------| | Starter | $25 | 5,000 | $0.005 | - | | Growth | $100 | 25,000 | $0.004 | 20% | | Enterprise | $500 | 200,000 | $0.0025 | 50% |

Volume Pricing Tiers

High-volume users get automatic discounts based on monthly event count:

| Tier | Monthly Events | Price/Event | Savings | |------|----------------|-------------|---------| | Standard | 0 - 100k | $0.005 | - | | Growth | 100k - 1M | $0.0025 | 50% | | Scale | 1M+ | $0.001 | 80% |

Event Types & Pricing

| Event | Default Price | Tier | |-------|---------------|------| | message | $0.005 | standard | | data_access | $0.005 | standard | | sensor_reading | $0.005 | standard | | api_call | $0.005 | standard | | unlock | $0.05 | premium | | stream_minute | $0.02 | premium | | compute_second | $0.0005 | micro | | storage_mb | $0.0005 | micro |

API Reference

createAccount(input)

Create a new IoT account. Returns the account and a one-time API key.

rotateApiKey(accountId)

Rotate the API key for an account. The old key is invalidated immediately.

registerDevice(input)

Register a device to an account.

getBalance(deviceId)

Check device/account balance.

meter(input) / chargePerMessage() / chargeForData()

Record billable events and deduct credits.

transfer(input)

Send payment from one device to another.

  • Minimum transfer: $0.05
  • Fee: 2% + $0.02

topup(input)

Add credits to account via Stripe.

Transfer Fees

  • Percentage: 2%
  • Flat Fee: $0.02
  • Minimum Fee: $0.02
  • Minimum Transfer: $0.05
  • Example: $10 transfer → $0.22 fee → $9.78 received
import { calculateTransferFee, MIN_TRANSFER_AMOUNT } from '@coinrailz/iot-payments';

const { fee, netAmount } = calculateTransferFee(10.00);
// fee: 0.22, netAmount: 9.78

console.log(`Minimum transfer: $${MIN_TRANSFER_AMOUNT}`);
// Minimum transfer: $0.05

Constants

import { 
  CREDITS_PACKS,
  EVENT_TYPES,
  TRANSFER_FEE,
  MIN_TRANSFER_AMOUNT 
} from '@coinrailz/iot-payments';

Payment Methods

Credit topups are supported via:

  • Stripe - Credit/debit card payments
  • PayPal - PayPal account or card
// Stripe topup (direct charge with payment method)
await iot.topup({
  accountId: account.id,
  packId: 'growth_100',
  paymentMethod: 'stripe',
  stripePaymentMethodId: 'pm_xxx'
});

// PayPal topup (2-step flow)
// Step 1: Create order
const order = await iot.topup({
  accountId: account.id,
  packId: 'growth_100',
  paymentMethod: 'paypal'
});
// Redirect user to order.approvalUrl

// Step 2: Capture after approval
await iot.topup({
  accountId: account.id,
  packId: 'growth_100',
  paymentMethod: 'paypal',
  paypalOrderId: order.paypalOrderId
});

Environment Variables

COINRAILZ_API_KEY=iot_your-api-key-here
COINRAILZ_BASE_URL=https://coinrailz.com

License

MIT