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

@nanosession/rpc

v0.2.0

Published

Nano RPC client with failover support

Downloads

336

Readme

@nanosession/rpc

Nano RPC client with multi-endpoint failover and exponential backoff retry.

Installation

pnpm add @nanosession/rpc

Usage

import { NanoRpcClient } from '@nanosession/rpc';

const client = new NanoRpcClient({
  endpoints: ['https://rpc.nano.to'],
  maxRetries: 3,
  retryDelayMs: 1000,
  timeoutMs: 30000
});

// Get block info
const blockInfo = await client.getBlockInfo('BLOCK_HASH');

// Get account info
const accountInfo = await client.getAccountInfo('nano_address');

// Generate proof-of-work
const work = await client.generateWork('FRONTIER_HASH');

URL Query Parameter Convention

RPC endpoint URLs support query parameters that are automatically merged into each RPC request body. This enables API key authentication for paid RPC services:

// API key is extracted from URL and merged into every RPC body
const client = new NanoRpcClient({
  endpoints: ['https://rpc.nano.to?key=YOUR_API_KEY']
});

// The request body will include: { action: "block_info", key: "YOUR_API_KEY", ... }
const info = await client.getBlockInfo('HASH');

Multiple Parameters

All query parameters are extracted and merged:

const client = new NanoRpcClient({
  endpoints: ['https://rpc.example.com?key=ABC&token=XYZ']
});
// Every request body includes: { ..., key: "ABC", token: "XYZ" }

Failover with Different Credentials

Each endpoint can have its own credentials:

const client = new NanoRpcClient({
  endpoints: [
    'https://primary.example.com?key=PRIMARY_KEY',
    'https://backup.example.com?key=BACKUP_KEY'
  ]
});

API

NanoRpcClient

Constructor Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | endpoints | string[] | (required) | RPC endpoint URLs (query params extracted and merged into body) | | maxRetries | number | 3 | Maximum retries per endpoint | | retryDelayMs | number | 1000 | Initial retry delay (doubles each retry) | | timeoutMs | number | 30000 | Request timeout in milliseconds |

Methods

  • getBlockInfo(hash: string): Promise<BlockInfo> - Get block information by hash
  • receivableExists(hash: string): Promise<boolean> - Check if a send block is still receivable
  • confirmBlock(hash: string): Promise<void> - Trigger election for a block
  • getAccountInfo(address: string): Promise<AccountInfo> - Get account information
  • getAccountHistory(account: string, count?: number): Promise<AccountHistoryEntry[]> - Get transaction history
  • processBlock(block: Record<string, unknown>): Promise<string> - Broadcast a signed block
  • generateWork(hash: string, difficulty?: string): Promise<string> - Request PoW generation
  • getActiveDifficulty(): Promise<string \| undefined> - Get current network difficulty

Documentation

Full protocol specification and guides: https://csi.ninzin.net/x402.NanoSession/

License

MIT