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

@payagent/sdk

v0.2.1

Published

PayAgent SDK — client for PayAgent crypto payments. Handles payment instructions, signing, broadcasting, and verification.

Readme

@payagent/sdk

SDK for PayAgent crypto payments. Uses HMAC-SHA256 request signing — your api_secret never leaves your environment.

Install

npm install @payagent/sdk ethers

Requires Node.js >= 18 and ethers v6+.

Quick Start

const { PayAgentClient } = require('@payagent/sdk');

const client = new PayAgentClient({
  apiKeyId: 'pk_live_YOUR_KEY_ID',
  apiSecret: 'sk_live_YOUR_SECRET',
  privateKey: process.env.WALLET_PRIVATE_KEY,
  baseUrl: 'https://payagent.vercel.app',
});

// Pay a link in one call
const result = await client.payLink('REQ-ABC123');
console.log(result.status);        // 'PAID'
console.log(result.transactions);  // [{ txHash: '0x...', status: 'confirmed' }, ...]

How It Works

Agent                  PayAgent API           Blockchain
  |                       |                      |
  |-- HMAC-signed req --->|                      |
  |<-- transfer list -----|                      |
  |                       |                      |
  |-- sign & broadcast --------------------------->|
  |<-- tx receipts --------------------------------|
  |                       |                      |
  |-- HMAC-signed verify ->|                      |
  |<-- PAID --------------|                      |
  1. Fetch instructions — SDK calls POST /api/pay-link with HMAC-signed headers
  2. Sign & broadcast — SDK signs each transaction locally with ethers.js
  3. Verify — SDK sends the resulting transaction hashes to POST /api/verify

All API requests are authenticated via HMAC-SHA256 (x-api-key-id, x-timestamp, x-signature headers). The api_secret is only used locally for signature computation.

Full Example

const { PayAgentClient } = require('@payagent/sdk');

// Initialize
const client = new PayAgentClient({
  apiKeyId: 'pk_live_YOUR_KEY_ID',
  apiSecret: 'sk_live_YOUR_SECRET',
  privateKey: process.env.WALLET_PRIVATE_KEY,
  baseUrl: 'https://payagent.vercel.app',
});

console.log('Wallet address:', client.address);

// Create a payment link
const link = await client.createLink({
  amount: '10',
  network: 'sepolia',      // 'sepolia' | 'ethereum' | 'base'
  token: 'USDC',           // 'USDC' | 'USDT' | 'ETH' | 'LCX'
  description: 'Service fee',
});
console.log('Link created:', link.linkId);

// Pay a link (one call — handles everything)
const result = await client.payLink(link.linkId);
console.log('Status:', result.status);
for (const tx of result.transactions) {
  console.log(`  ${tx.description}: ${tx.txHash} (${tx.status})`);
}

// Or step-by-step for more control:
const instructions = await client.getInstructions('REQ-ABC123');
// ... sign & broadcast yourself ...
const verification = await client.verifyPayment('REQ-ABC123', '0xTxHash');

HMAC Signing

Every request is signed with HMAC-SHA256. The string-to-sign format is:

timestamp\nMETHOD\npath\nSHA256(body)

The SDK computes this automatically. For manual curl usage, see the API documentation.

API Reference

new PayAgentClient(options)

| Option | Type | Required | Description | |--------|------|----------|-------------| | apiKeyId | string | yes | Your PayAgent API key ID (pk_live_...) | | apiSecret | string | yes | Your PayAgent API secret (sk_live_...) — used for HMAC signing | | privateKey | string | yes | Your wallet private key | | baseUrl | string | no | API base URL (default: https://payagent.vercel.app) | | rpcUrl | string or object | no | Custom RPC URL. String for all chains, or { sepolia: '...', ethereum: '...', base: '...' } |

client.payLink(linkId) -> Promise

Pay a link in one call. Fetches instructions, signs, broadcasts, and verifies.

Returns:

{
  success: true,
  linkId: 'REQ-ABC123',
  payer: '0xYourAddress',
  network: 'sepolia',
  transactions: [
    { description: 'Payment to creator', txHash: '0x...', token: 'USDC', amount: '10', status: 'confirmed' },
    { description: 'Platform fee', txHash: '0x...', token: 'LCX', amount: '2', status: 'confirmed' },
    { description: 'Creator reward', txHash: '0x...', token: 'LCX', amount: '2', status: 'confirmed' }
  ],
  verification: { success: true, status: 'PAID' },
  status: 'PAID'
}

client.createLink({ amount, network, token?, description? }) -> Promise

Create a new payment link.

client.getInstructions(linkId) -> Promise

Fetch payment instructions without executing. Use for manual control.

client.verifyPayment(requestId, txHash, feeTxHash?, rewardTxHash?) -> Promise

Verify a payment by transaction hash(es).

client.getChains() -> Promise

Fetch supported chains from the API.

client.address -> string

The wallet address derived from your private key.

Migration from v0.1.x

v0.2.0 is a breaking change. The constructor now requires apiKeyId + apiSecret instead of apiKey:

// Before (v0.1.x)
const client = new PayAgentClient({ apiKey: 'pk_live_...', privateKey: '0x...' });

// After (v0.2.0)
const client = new PayAgentClient({ apiKeyId: 'pk_live_...', apiSecret: 'sk_live_...', privateKey: '0x...' });

Rotate your key via POST /api/agents/rotate-key to get the new api_key_id + api_secret credentials.

Custom RPC URLs

For better reliability, provide your own RPC URLs:

const client = new PayAgentClient({
  apiKeyId: 'pk_live_...',
  apiSecret: 'sk_live_...',
  privateKey: '0x...',
  rpcUrl: {
    sepolia: 'https://sepolia.infura.io/v3/YOUR_KEY',
    ethereum: 'https://mainnet.infura.io/v3/YOUR_KEY',
    base: 'https://base-mainnet.infura.io/v3/YOUR_KEY',
  },
});

Supported Chains

  • Sepolia (ETH Testnet) — sepolia
  • Ethereum Mainnetethereum
  • Base Mainnetbase

Tokens per chain: USDC, USDT, ETH (native), LCX.

License

MIT