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

@mugdha26/eigenx402-client-sdk

v1.0.0

Published

Client SDK for EigenX402 - Pay-per-use AI inference with crypto payments

Readme

@eigenx402/client-sdk

Client SDK for EigenX402 - Pay-per-use AI inference with crypto payments in a TEE.

Installation

npm install @mugdha26/eigenx402-client-sdk ethers

Quick Start

import { EigenX402Client } from '@eigenx402/client-sdk';
import { ethers } from 'ethers';

// Connect wallet
const provider = new ethers.providers.Web3Provider(window.ethereum);
const signer = provider.getSigner();

// Initialize client
const client = new EigenX402Client({
  serverUrl: 'http://34.9.138.101:8080',
  signerOrProvider: signer
});

// Make paid AI request
const result = await client.makeX402Request('/api/generate-text', {
  method: 'POST',
  body: {
    prompt: "Explain quantum computing",
    model: "gpt-oss-120b-f16",
    seed: 42
  }
});

console.log(result.output);      // AI response
console.log(result.proof);       // Cryptographic proof
console.log(result.txHash);      // Payment transaction hash

Features

  • Automatic Payment Handling - SDK manages the complete x402 payment flow
  • EIP-3009 Signatures - USDC transferWithAuthorization for gasless payments
  • TypeScript Support - Full type definitions included
  • Error Handling - Clear error messages and retries
  • Verifiable Compute - Get cryptographic proofs with every response

API Reference

EigenX402Client

Main client for making paid requests.

Constructor

new EigenX402Client(config: ClientConfig)

ClientConfig:

  • serverUrl: string - TEE service endpoint
  • signerOrProvider?: ethers.Signer - Wallet signer (optional, can set later)

Methods

makeX402Request<T>(endpoint, options?)

Make a paid request to any x402-protected endpoint.

Parameters:

  • endpoint: string - API endpoint path (e.g., /api/generate-text)
  • options?: object
    • method?: string - HTTP method (default: 'POST')
    • body?: any - Request body
    • headers?: Record<string, string> - Additional headers

Returns: Promise<T> - Response from the API

Example:

const result = await client.makeX402Request('/api/generate-text', {
  method: 'POST',
  body: { prompt: "Hello", seed: 42 }
});
setSigner(signer)

Set or update the wallet signer.

Parameters:

  • signer: ethers.Signer - ethers.js Signer instance

Example:

const signer = provider.getSigner();
client.setSigner(signer);

Response Format

All requests return:

{
  jobId: string;           // Unique job identifier
  output: string;          // AI-generated response
  proof: {
    modelHash: string;     // SHA-256 of model
    inputHash: string;     // SHA-256 of input
    outputHash: string;    // SHA-256 of output
    containerImageDigest: string;  // TEE container digest
    producedAt: string;    // ISO timestamp
    attestation: string | null;    // TEE attestation
  };
  txHash: string;          // Payment transaction hash
  status: 'completed';
}

Payment Flow

  1. Initial Request - SDK makes request without payment
  2. 402 Response - Server returns payment requirements
  3. Sign Payment - SDK prompts wallet to sign USDC authorization
  4. Retry with Payment - SDK retries request with payment proof
  5. Get Result - Server processes payment and returns AI response

Requirements

  • Wallet: MetaMask or any Web3 wallet
  • Network: Base Sepolia testnet
  • Tokens:

Error Handling

try {
  const result = await client.makeX402Request('/api/generate-text', {
    body: { prompt: "Hello", seed: 42 }
  });
} catch (error) {
  if (error.message.includes('Payment Required')) {
    // User needs to approve payment
  } else if (error.message.includes('Insufficient balance')) {
    // User needs more USDC
  } else {
    // Other error
    console.error(error);
  }
}

TypeScript

Full TypeScript support with type definitions:

import type { 
  JobResult, 
  ClientConfig,
  X402PaymentPayload 
} from '@mugdha26/eigenx402-client-sdk';

Links

License

MIT