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

@atxp/x402

v0.10.5

Published

ATXP X402 - X402 protocol integration for ATXP SDK

Readme

@atxp/x402

X402 protocol integration for ATXP SDK - enables automatic HTTP 402 payment handling using the X402 standard.

Overview

The @atxp/x402 package provides a fetch wrapper that automatically handles X402 payment challenges. When a server responds with a 402 Payment Required status and X402 headers, this wrapper will:

  1. Parse the X402 payment requirements
  2. Create and submit payments using your ATXP account
  3. Retry the original request with payment proof
  4. Handle payment failures and retries

Documentation

For complete documentation, refer to our docs page.

Installation

npm install @atxp/x402

Prerequisites

  • An ATXP account (ATXPAccount instance)
  • Compatible with networks that support X402 payments
  • Requires x402 library for payment processing

Usage

Basic Usage

import { wrapWithX402 } from '@atxp/x402';
import { ATXPAccount } from '@atxp/client';

// Create your ATXP account
const account = new ATXPAccount({
  // your account configuration
});

// Wrap fetch with X402 payment handling
const paymentEnabledFetch = wrapWithX402({
  account,
  mcpServer: 'https://your-mcp-server.com'
});

// Use the wrapped fetch - payments will be handled automatically
const response = await paymentEnabledFetch('https://api.example.com/premium-data');

How It Works

  1. Request Interception: The wrapper intercepts all HTTP requests
  2. 402 Detection: When a 402 Payment Required response is received, it checks for X402 headers
  3. Payment Processing: Uses the x402 library to parse payment requirements and create payments
  4. Account Integration: Leverages your ATXPAccount for payment submission
  5. Request Retry: Automatically retries the original request with payment proof

X402 Protocol Support

This package implements the X402 HTTP payment protocol, which standardizes how web services can request payments for access to resources. Key features:

  • Automatic parsing of X402 payment headers
  • Support for multiple payment methods and currencies
  • Retry logic for failed payments
  • Integration with ATXP's payment infrastructure

Error Handling

The wrapper handles various error scenarios:

  • Invalid Account: Throws error if non-ATXPAccount is provided
  • Payment Failures: Calls onPaymentFailure callback and may retry
  • Network Errors: Passes through non-payment related errors
  • Unsupported X402: Gracefully handles servers with incomplete X402 implementation

Dependencies

  • @atxp/client: ATXP client library with ATXPAccount
  • @atxp/common: Shared ATXP utilities and types
  • x402: X402 protocol implementation
  • viem: Ethereum utilities
  • bignumber.js: Precise decimal arithmetic

License

MIT