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

@rlock/cpsr-sdk

v0.1.0

Published

TypeScript SDK for CPSR-Lite - Build, submit, and manage Solana transactions with compute budgets and ALT support

Readme

@cpsr/sdk

TypeScript SDK for CPSR-Lite - Build, submit, and manage Solana transactions with compute budgets and Address Lookup Table support.

Features

  • 🎯 Typed Intent Builders - Create transactions with type-safe intent builders
  • 💰 Fee Management - Basic and adaptive fee policies (p75, EMA, hysteresis)
  • 🔗 ALT Support - Pluggable Address Lookup Table resolution
  • 🚀 Multiple Submission Lanes - L1 (direct RPC) and Router (Magic Router)
  • Compute Budget - Automatic CU limit/price injection
  • 🧪 Well Tested - Unit and E2E tests with solana-test-validator

Installation

npm install @cpsr/sdk

Quick Start

import { Connection, Keypair } from '@solana/web3.js';
import { CpsrClient, transferIntent, SubmitLane } from '@cpsr/sdk';

// Initialize client
const connection = new Connection('https://api.devnet.solana.com');
const payer = Keypair.fromSecretKey(/* your secret key */);

const client = new CpsrClient({
  connection,
  payer,
  routerUrl: 'https://devnet-router.magicblock.app', // Optional
});

// Build an intent
const intent = transferIntent({
  from: payer.publicKey,
  to: recipientPublicKey,
  lamports: 1_000_000,
});

// Submit transaction
const result = await client.buildAndSubmit({
  intents: [intent],
  cuPrice: 5_000,
  cuLimit: 200_000,
  submitOptions: {
    lane: SubmitLane.L1, // or SubmitLane.Router
  },
});

console.log('Signature:', result.signature);

Advanced Usage

Using Recent Fees Policy

import { CpsrClient } from '@cpsr/sdk';

const client = CpsrClient.withRecentFees({
  connection,
  payer,
  percentile: 0.75, // Use p75 of recent fees
  useEma: true,     // Enable EMA smoothing
  useHysteresis: true, // Avoid frequent price changes
});

Building with ALT Support

import { CpsrClient, StaticAltSource } from '@cpsr/sdk';
import { AddressLookupTableAccount } from '@solana/web3.js';

const altSource = new StaticAltSource([
  /* your ALT accounts */
]);

const client = new CpsrClient({
  connection,
  payer,
  altSource,
});

Tightening Compute Units

// Simulate to tighten CU limit before submission
const tx = await client.build({
  intents: [intent],
  cuLimit: 1_000_000,
  cuPrice: 5_000,
  tighten: true, // Simulate and adjust CU limit
});

const result = await client.submit(tx);

Custom Intents

import { customIntent } from '@cpsr/sdk';
import { TransactionInstruction } from '@solana/web3.js';

const ix = new TransactionInstruction({
  programId: yourProgramId,
  keys: [/* account metas */],
  data: Buffer.from([/* instruction data */]),
});

const intent = customIntent({
  actor: payer.publicKey,
  instruction: ix,
  options: { priority: 10 },
});

API Documentation

Full API documentation is available in the docs/ directory after building:

npm run docs

Development

# Install dependencies
npm install

# Build
npm run build

# Run tests
npm test

# Run unit tests only
npm run test:unit

# Run E2E tests (requires solana-test-validator)
npm run test:e2e

# Generate docs
npm run docs

# Lint
npm run lint

Testing

Unit Tests

Unit tests cover core functionality without external dependencies:

npm run test:unit

E2E Tests

E2E tests require solana-test-validator to be installed and available in PATH:

npm run test:e2e

The E2E tests include:

  • Basic transfer submission
  • Memo instruction handling
  • Hot account scenarios with retries
  • Compute unit tightening

Architecture

The SDK is structured into modules:

  • intents/ - Intent types and builders
  • tx/ - Transaction building, fee policies, ALT resolution
  • submit/ - Submission strategies (L1, Router)
  • errors.ts - Typed error classes
  • client.ts - Main unified client

Error Handling

The SDK provides typed errors for different failure scenarios:

import {
  BlockhashStaleError,
  PreflightFailedError,
  RpcRetriableError,
  TransactionTooLargeError,
  RouterJsonRpcError,
  NetworkError,
} from '@cpsr/sdk';

try {
  await client.buildAndSubmit({ /* ... */ });
} catch (error) {
  if (error instanceof BlockhashStaleError) {
    // Retry with fresh blockhash
  } else if (error instanceof RpcRetriableError) {
    // Backoff and retry
  } else if (error instanceof PreflightFailedError) {
    // Transaction would fail, investigate logs
    console.error('Preflight logs:', error.logs);
  }
}

Publishing

This package uses npm's trusted publishing via GitHub Actions OIDC. To publish:

  1. Update version in package.json
  2. Create and push a git tag:
    git tag v0.1.0
    git push origin v0.1.0
  3. GitHub Actions will automatically build, test, and publish to npm

Contributing

Contributions are welcome! Please ensure:

  • All tests pass (npm test)
  • Code is linted (npm run lint)
  • Documentation is updated (npm run docs)

License

MIT

Links