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

@courierprotocol/sdk

v0.1.27

Published

Official SDK for interacting with the Courier Protocol on Solana. This SDK provides a simple and powerful interface for creating, managing, and consuming one-time action codes on the Solana blockchain.

Readme

@courierprotocol/sdk

Official SDK for interacting with the Courier Protocol on Solana. This SDK provides a simple and powerful interface for creating, managing, and consuming one-time action codes on the Solana blockchain.

Installation

npm install @courierprotocol/sdk
# or
yarn add @courierprotocol/sdk
# or
pnpm add @courierprotocol/sdk

Quick Start

import { Client } from '@courierprotocol/sdk';
import { Connection, clusterApiUrl } from '@solana/web3.js';
import { Wallet } from '@coral-xyz/anchor';

// Initialize the SDK with a Solana connection
const connection = new Connection(clusterApiUrl('devnet'));
const wallet = new Wallet(Keypair.generate()); // Your wallet implementation

const client = new Client({
  connection,
  wallet,
});

// Use the carrier service to create and manage codes
const code = await client.carrier.claimCode({
  type: 'solanaPay',
  amount: 1.0,
  recipient: 'H7fubezu5B76NMjsQGNcEdaZWXgXRDtTd7NQjAeTY6W3',
});

Features

Carrier Service

The carrier service handles the creation and management of one-time action codes:

  • Code Management

    • Claim codes
    • Resolve codes
    • Consume codes
    • Update transaction hashes
    • Get active codes
  • Payload Creation

    • Solana Pay payloads
    • Solana Action payloads
    • Custom Transaction payloads

Protocol Services

The SDK provides two protocol services for different use cases:

  1. User Protocol

    • Register users
    • Hash user codes
    • Manage user-specific operations
  2. Entity Protocol

    • Register entities
    • Hash entity codes
    • Manage entity-specific operations

Usage Examples

Creating a Solana Pay Code

// Create a Solana Pay payload
const payload = client.carrier.createSolanaPayPayload(
  'H7fubezu5B76NMjsQGNcEdaZWXgXRDtTd7NQjAeTY6W3',
  1.0,
  'Payment for services'
);

// Claim the code
const code = await client.carrier.claimCode({
  type: 'solanaPay',
  amount: 1.0,
  recipient: 'H7fubezu5B76NMjsQGNcEdaZWXgXRDtTd7NQjAeTY6W3',
  memo: 'Payment for services',
});

Creating a Custom Transaction Code

// Create a custom transaction payload
const instructions = [
  new TransactionInstruction({
    programId: new PublicKey('Stake11111111111111111111111111111111111111'),
    keys: [
      {
        pubkey: wallet.publicKey,
        isSigner: true,
        isWritable: true,
      },
      {
        pubkey: new PublicKey('H7fubezu5B76NMjsQGNcEdaZWXgXRDtTd7NQjAeTY6W3'),
        isSigner: false,
        isWritable: true,
      },
    ],
    data: Buffer.from([0]), // Stake instruction
  }),
];

const payload = client.carrier.createCustomTransactionPayload(
  instructions,
  { memo: 'Staking 1 SOL' },
  [wallet.publicKey.toBase58()]
);

// Claim the code
const code = await client.carrier.claimCode({
  type: 'customTransaction',
  instructions,
  parameters: { memo: 'Staking 1 SOL' },
  signers: [wallet.publicKey.toBase58()],
});

Consuming a Code

// Resolve the code first
const resolved = await client.carrier.resolveCode('12345678');

// Consume the code with an action
const result = await client.carrier.consumeCode('12345678', {
  action: {
    type: 'solanaPay',
    chain: 'solana',
    payload: resolved.payload,
  },
  consumer: wallet.publicKey.toBase58(),
});

Error Handling

The SDK provides comprehensive error handling with specific error codes and messages:

try {
  await client.carrier.claimCode({ /* ... */ });
} catch (error) {
  if (error instanceof Error) {
    console.error(`Failed to claim code: ${error.message}`);
  }
}

API Reference

Client

The main entry point for the SDK.

interface ClientOptions {
  connection: Connection;
  wallet?: Wallet;
  opts?: ConfirmOptions;
}

class Client {
  constructor(options: ClientOptions);
  get carrier(): CarrierService;
  get entityProtocol(): EntityCourierProtocolSDK;
  get userProtocol(): UserCourierProtocolSDK;
  updateWallet(wallet: Wallet): void;
}

CarrierService

Handles code management and payload creation.

class CarrierService {
  createSolanaPayPayload(recipient: string, amount: number, memo?: string, splToken?: string): Payload;
  createSolanaActionPayload(title: string, description: string, recipient: string, amount: number, icon?: string): Payload;
  createCustomTransactionPayload(instructions: TransactionInstruction[], parameters?: Record<string, any>, signers?: string[]): Payload;
  parseToUnifiedUIPayload(payload: Payload): UnifiedUIPayload;
  toWalletTx(payload: Payload): Promise<Transaction>;
  signAndSend(payload: Payload): Promise<string>;
  claimCode(opts: ClaimRequest): Promise<ClaimResponse>;
  getActiveCode(): Promise<ClaimResponse>;
  resolveCode(code: string): Promise<ResolveResponse>;
  consumeCode(code: string, opts: ConsumeRequest): Promise<ConsumeResponse>;
  updateTransactionHash(code: string, transactionHash: string): Promise<ResolveResponse>;
}

Payload Helpers

The SDK provides several payload helper methods to create different types of transaction payloads:

1. Solana Pay Payload

Used for simple SOL or SPL token transfers.

const payload = client.carrier.createSolanaPayPayload(
  recipient: string,      // Recipient's public key
  amount: number,         // Amount to transfer
  memo?: string,          // Optional memo
  splToken?: string       // Optional SPL token mint address
);

2. Solana Action Payload

Used for creating interactive actions with custom UI elements.

const payload = client.carrier.createSolanaActionPayload(
  title: string,          // Action title
  description: string,    // Action description
  recipient: string,      // Recipient's public key
  amount: number,         // Amount involved
  icon?: string          // Optional icon URL
);

3. Custom Transaction Payload

Used for complex transactions with custom instructions.

const payload = client.carrier.createCustomTransactionPayload(
  instructions: TransactionInstruction[],  // Array of transaction instructions
  parameters?: Record<string, any>,        // Optional parameters
  signers?: string[]                       // Optional array of signer public keys
);

4. Unified UI Payload

Converts any payload type into a standardized format for UI display.

const unifiedPayload = client.carrier.parseToUnifiedUIPayload(payload);

5. Transaction Conversion

Convert a payload to a Solana transaction for signing and sending.

const transaction = await client.carrier.toWalletTx(payload);
const signature = await client.carrier.signAndSend(payload);