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

@kwespay/client

v0.1.23

Published

TypeScript SDK for KwesPay — accept crypto payments in three steps.

Readme

@kwespay/client

TypeScript SDK for KwesPay — accept crypto payments in your app with minimal setup.

All pricing, signing, and contract addresses are managed server-side. You initialise the client, request a quote, and execute the payment. Nothing else is required.


Prerequisites

Before installing the SDK, you need a KwesPay vendor account and an API key.

  1. Go to app.kwespay.xyz and create an account
  2. Create a vendor profile — this gives you your Vendor ID
  3. Navigate to API Keys and generate a key — this is your API Key

Keep both values handy; you will need them to initialise the client.


Installation

npm install @kwespay/client
yarn add @kwespay/client
pnpm add @kwespay/client

Requirements

  • Node.js 18+
  • TypeScript 5+
  • An EIP-1193 compatible wallet provider (MetaMask, WalletConnect, etc.)
  • A KwesPay API key (see Prerequisites)

Quick Start

import { KwesPayClient } from "@kwespay/client";

const client = new KwesPayClient({ apiKey: "your-api-key" });

const payload = await client.quote({
  vendorIdentifier: "your-vendor-id",
  fiatAmount: 10,
  fiatCurrency: "USD",
  cryptoCurrency: "USDC",
  network: "base",
  payerWalletAddress: "0xabc...",
});

const result = await client.pay({
  provider: window.ethereum,
  payload,
  onStatus: (title, detail) => console.log(title, detail),
});

console.log(result.txHash);

API Reference

new KwesPayClient(config)

Creates a new client instance.

| Parameter | Type | Required | Description | |---|---|---|---| | config.apiKey | string | Yes | Your KwesPay API key |


client.validateKey()

Validates the configured API key and returns its scope.

const result = await client.validateKey();

if (result.isValid) {
  console.log(result.vendorInfo);
  console.log(result.scope.allowedNetworks);
} else {
  console.error(result.error);
}

Returns{ isValid: true, keyId, keyLabel, activeFlag, expirationDate, vendorInfo, scope } or { isValid: false, error }.


client.quote(params)

Fetches a price quote and prepares a transaction payload in a single call. The returned payload is passed directly to client.pay().

const payload = await client.quote({
  vendorIdentifier: "your-vendor-id",
  fiatAmount: 25.00,
  fiatCurrency: "USD",        // optional, defaults to "USD"
  cryptoCurrency: "USDC",
  network: "base",
  payerWalletAddress: "0xabc...",
});

| Parameter | Type | Required | Description | |---|---|---|---| | vendorIdentifier | string | Yes | Your vendor UUID from app.kwespay.xyz | | fiatAmount | number | Yes | Amount in fiat to charge | | fiatCurrency | string | No | Fiat currency code. Defaults to "USD" | | cryptoCurrency | TokenSymbol | Yes | Token to accept | | network | NetworkKey | Yes | Target blockchain network | | payerWalletAddress | string | Yes | The payer's wallet address |

ReturnsTransactionPayload


client.pay(params)

Executes the on-chain payment. Handles network switching, token approval, and transaction submission automatically.

const result = await client.pay({
  provider: window.ethereum,
  payload,
  onStatus: (title, detail) => {
    console.log(`[${title}] ${detail}`);
  },
});

| Parameter | Type | Required | Description | |---|---|---|---| | provider | EIP1193Provider | Yes | Wallet provider | | payload | TransactionPayload | Yes | Payload from client.quote() | | onStatus | (title, detail) => void | No | Progress callback |

The onStatus callback fires at each stage of the payment flow:

| Title | Fired when | |---|---| | Checking balance | Verifying wallet has sufficient funds | | Switching network | Requesting network change in wallet | | Checking approval | Reading current ERC-20 allowance | | Approve token | Requesting ERC-20 approval from user | | Waiting for approval | Approval tx is confirming on-chain | | Confirm payment | Requesting payment tx from user | | Waiting for confirmation | Payment tx is confirming on-chain |

ReturnsPaymentResult

interface PaymentResult {
  txHash: string;
  blockNumber: number;
  transactionReference: string;
  paymentIdBytes32: string;
}

client.getTransactionStatus(transactionReference)

Polls the KwesPay backend for the current status of a transaction.

const status = await client.getTransactionStatus("txn_ref_here");
console.log(status.transactionStatus); // "completed"

ReturnsTransactionStatusResult

interface TransactionStatusResult {
  transactionReference: string;
  transactionStatus: TransactionStatus;
  blockchainHash: string | null;
  blockchainNetwork: string | null;
  displayAmount: number;
  cryptoCurrency: string;
  payerWalletAddress: string;
  initiatedAt: string;
}

Supported Networks

| Key | Network | |---|---| | ethereum | Ethereum Mainnet | | sepolia | Ethereum Sepolia (testnet) | | base | Base Mainnet | | baseSepolia | Base Sepolia (testnet) | | polygon | Polygon Mainnet | | polygonAmoy | Polygon Amoy (testnet) | | lisk | Lisk Mainnet | | liskTestnet | Lisk Testnet | | MezoTestnet | Mezo Testnet |


Supported Tokens

ETH, MATIC, USDT, USDC, USDC.E, USDBC, DAI, LSK, MUSD

Custom token addresses are also accepted as a plain string.


Error Handling

All errors are thrown as KwesPayError instances with a code property.

import { KwesPayClient, KwesPayError } from "@kwespay/client";

try {
  const payload = await client.quote({ ... });
  const result = await client.pay({ provider, payload });
} catch (err) {
  if (err instanceof KwesPayError) {
    switch (err.code) {
      case "WALLET_REJECTED":
        console.error("User cancelled the transaction.");
        break;
      case "INSUFFICIENT_BALANCE":
        console.error("Not enough funds:", err.message);
        break;
      case "WRONG_NETWORK":
        console.error("Network mismatch:", err.message);
        break;
      case "QUOTE_EXPIRED":
        console.error("Quote expired. Request a new one.");
        break;
      default:
        console.error(`Payment failed [${err.code}]:`, err.message);
    }
  }
}

Error Codes

| Code | Description | |---|---| | INVALID_KEY | API key is missing, invalid, or inactive | | QUOTE_EXPIRED | Quote TTL has elapsed | | QUOTE_USED | Quote has already been used for a transaction | | QUOTE_NOT_FOUND | Quote ID does not exist | | TRANSACTION_FAILED | Payload is missing required fields | | WALLET_REJECTED | User rejected the transaction in their wallet | | APPROVAL_REJECTED | User rejected the ERC-20 approval in their wallet | | INSUFFICIENT_BALANCE | Wallet lacks funds or gas | | CONTRACT_ERROR | On-chain call reverted or receipt timed out | | WRONG_NETWORK | Wallet is on the wrong chain and could not switch | | NETWORK_ERROR | HTTP or connectivity failure reaching the API | | UNKNOWN | Unclassified server-side error |


TypeScript

The SDK is written in TypeScript and ships its own types. No additional @types packages are required.

Key types exported from the package:

import type {
  KwesPayConfig,
  QuoteParams,
  TransactionPayload,
  TransactionStatus,
  TransactionStatusResult,
  PayParams,
  PaymentResult,
  NetworkKey,
  TokenSymbol,
  EIP1193Provider,
  KwesPayErrorCode,
} from "@kwespay/client";

License

MIT