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

cronos-merchant-sdk

v1.0.2

Published

A robust, multi-chain agent client that enables your AI Agents to pay for APIs autonomously.

Downloads

89

Readme

Cronos Merchant SDK

A robust, multi-chain agent client that enables your AI Agents to pay for APIs autonomously.

Key features:

  • Automatic 402 Payments: Handles "Payment Required" challenges seamlessly.
  • Multi-Chain: Auto-negotiates with backends (EVM/Solana support).
  • Safe: Built-in daily spending limits and policy controls.
  • Type-Safe: Generic fetch and structured AgentError handling.

Installation

npm install @cronos-merchant/sdk ethers

Quick Start

import { AgentClient, AgentError } from "@cronos-merchant/sdk";

// 1. Initialize
const agent = new AgentClient({
  privateKey: process.env.AGENT_KEY,
  rpcUrl: "https://evm-t3.cronos.org", // Cronos Testnet
  chainId: 338,
  usdcAddress: "0xc01..." // Your payment token
});

async function main() {
  try {
    // 2. Fetch paid resources (just like axios/fetch)
    const response = await agent.fetch<{ answer: string }>("http://localhost:3000/premium", {
        method: "POST",
        body: { prompt: "Hello World" }
    });
    
    console.log("Success:", response.answer);

  } catch (err: any) {
    // 3. Handle Errors
    if (err instanceof AgentError) {
        console.error(`Status: ${err.status}`); // 402, 500
        console.error(`Code: ${err.code}`);     // POLICY_REJECTED, NETWORK_ERROR
    }
  }
}

Configuration

new AgentClient(config)

| Option | Type | Required | Description | | :--- | :--- | :--- | :--- | | privateKey | string | Yes | EVM private key for the agent wallet. | | rpcUrl | string | Yes | RPC Endpoint (e.g., Cronos Testnet). | | chainId | number | Yes | Chain ID (e.g., 338). Sent to backend for negotiation. | | usdcAddress | string | Yes | ERC20 Token Address used for payment. | | dailyLimit | number | No | Max USDC allowed to spend per 24h. Default: 1.0 | | allowedMerchants | string[] | No | List of Merchant IDs to trust. If empty, allows all. | | trustedFacilitators | string[] | No | List of Gateway URLs to trust (e.g., localhost). |

API Reference

agent.fetch<T>(url, options): Promise<T>

Performs an HTTP request. If the server responds with 402 Payment Required:

  1. SDK parses the payment request (from Headers or Body).
  2. Checks spending policies (Daily Limit, Whitelist).
  3. Executes the payment on-chain.
  4. Retries the original request with the Payment Proof.

Generics: Pass the expected response type <T> for TypeScript autocomplete.

Options:

  • method: "GET" | "POST"
  • headers: Dictionary of headers.
  • body: JSON object or string.

AgentError

Thrown when a request fails or is blocked by policy.

  • err.status: The HTTP status code (e.g., 400, 402, 500).
  • err.code: A machine-readable string:
    • POLICY_REJECTED: Blocked by daily limit or whitelist.
    • INSUFFICIENT_FUNDS: Not enough USDC/Gas.
    • HTTP_ERROR: Server returned an error (details in err.details).
  • err.details: The raw response body from the server.

License

MIT