Catalog npm
Back to packageRELEASE DETAILS

0.6.14

npm

@0xcipher0/x402

x402 Payment Protocol

Published26 Oct 2025
Direct dependencies34
Transitive dependenciesNot calculated

README

Current package documentation

x402

Core TypeScript implementation of the x402 Payment Protocol. This package provides the foundational types, schemas, and utilities that power all x402 integrations.

Installation

npm install x402

Overview

The x402 package provides the core building blocks for implementing the x402 Payment Protocol in TypeScript. It's designed to be used by:

  • Middleware implementations (Express, Hono, Next.js)
  • Client-side payment handlers (fetch wrapper)
  • Facilitator services
  • Custom integrations

Integration Packages

This core package is used by the following integration packages:

  • x402-express: Express.js middleware
  • x402-hono: Hono middleware
  • x402-next: Next.js middleware
  • x402-fetch: Fetch API wrapper
  • x402-axios: Axios interceptor

Manual Server Integration

If you're not using one of our server middleware packages, you can implement the x402 protocol manually. Here's what you'll need to handle:

  1. Return 402 error responses with the appropriate response body
  2. Use the facilitator to validate payments
  3. Use the facilitator to settle payments
  4. Return the appropriate response header to the caller

For a complete example implementation, see our advanced server example which demonstrates both synchronous and asynchronous payment processing patterns.

Manual Client Integration

If you're not using our x402-fetch or x402-axios packages, you can manually integrate the x402 protocol in your client application. Here's how:

  1. Make a request to a x402-protected endpoint. The server will respond with a 402 status code and a JSON object containing:

    • x402Version: The version of the x402 protocol being used
    • accepts: An array of payment requirements you can fulfill
  2. Select the payment requirement you wish to fulfill from the accepts array

  3. Create the payment header using the selected payment requirement

  4. Retry your network call with:

    • The payment header assigned to the X-PAYMENT field
    • The Access-Control-Expose-Headers field set to "X-PAYMENT-RESPONSE" to receive the server's transaction response

For implementation examples, we recommend reviewing our official client packages:

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 35

Native requirements
34 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
@scure/base
Environment
{
  "local_name": "@scure/base",
  "alias": false,
  "peer_metadata": null
}
^1.2.6runtime
@solana-program/compute-budget
Environment
{
  "local_name": "@solana-program/compute-budget",
  "alias": false,
  "peer_metadata": null
}
^0.8.0runtime
@solana-program/token
Environment
{
  "local_name": "@solana-program/token",
  "alias": false,
  "peer_metadata": null
}
^0.5.1runtime
@solana-program/token-2022
Environment
{
  "local_name": "@solana-program/token-2022",
  "alias": false,
  "peer_metadata": null
}
^0.4.2runtime
@solana/kit
Environment
{
  "local_name": "@solana/kit",
  "alias": false,
  "peer_metadata": null
}
^2.1.1runtime
@solana/transaction-confirmation
Environment
{
  "local_name": "@solana/transaction-confirmation",
  "alias": false,
  "peer_metadata": null
}
^2.1.1runtime
viem
Environment
{
  "local_name": "viem",
  "alias": false,
  "peer_metadata": null
}
^2.21.26runtime
wagmi
Environment
{
  "local_name": "wagmi",
  "alias": false,
  "peer_metadata": null
}
^2.15.6runtime
zod
Environment
{
  "local_name": "zod",
  "alias": false,
  "peer_metadata": null
}
^3.24.2runtime
@coinbase/onchainkit
Environment
{
  "local_name": "@coinbase/onchainkit",
  "alias": false,
  "peer_metadata": null
}
^0.38.14development
@craftamap/esbuild-plugin-html
Environment
{
  "local_name": "@craftamap/esbuild-plugin-html",
  "alias": false,
  "peer_metadata": null
}
^0.9.0development
@eslint/js
Environment
{
  "local_name": "@eslint/js",
  "alias": false,
  "peer_metadata": null
}
^9.24.0development
@types/node
Environment
{
  "local_name": "@types/node",
  "alias": false,
  "peer_metadata": null
}
^22.13.4development
@types/react
Environment
{
  "local_name": "@types/react",
  "alias": false,
  "peer_metadata": null
}
^19development
@types/react-dom
Environment
{
  "local_name": "@types/react-dom",
  "alias": false,
  "peer_metadata": null
}
^19development
@typescript-eslint/eslint-plugin
Environment
{
  "local_name": "@typescript-eslint/eslint-plugin",
  "alias": false,
  "peer_metadata": null
}
^8.29.1development
@typescript-eslint/parser
Environment
{
  "local_name": "@typescript-eslint/parser",
  "alias": false,
  "peer_metadata": null
}
^8.29.1development
@wagmi/connectors
Environment
{
  "local_name": "@wagmi/connectors",
  "alias": false,
  "peer_metadata": null
}
^5.8.1development
@wagmi/core
Environment
{
  "local_name": "@wagmi/core",
  "alias": false,
  "peer_metadata": null
}
^2.17.1development
buffer
Environment
{
  "local_name": "buffer",
  "alias": false,
  "peer_metadata": null
}
^6.0.3development
esbuild
Environment
{
  "local_name": "esbuild",
  "alias": false,
  "peer_metadata": null
}
^0.25.4development
eslint
Environment
{
  "local_name": "eslint",
  "alias": false,
  "peer_metadata": null
}
^9.24.0development
eslint-plugin-import
Environment
{
  "local_name": "eslint-plugin-import",
  "alias": false,
  "peer_metadata": null
}
^2.31.0development
eslint-plugin-jsdoc
Environment
{
  "local_name": "eslint-plugin-jsdoc",
  "alias": false,
  "peer_metadata": null
}
^50.6.9development
eslint-plugin-prettier
Environment
{
  "local_name": "eslint-plugin-prettier",
  "alias": false,
  "peer_metadata": null
}
^5.2.6development
prettier
Environment
{
  "local_name": "prettier",
  "alias": false,
  "peer_metadata": null
}
3.5.2development
react
Environment
{
  "local_name": "react",
  "alias": false,
  "peer_metadata": null
}
^19.0.0development
react-dom
Environment
{
  "local_name": "react-dom",
  "alias": false,
  "peer_metadata": null
}
^19.0.0development
tsup
Environment
{
  "local_name": "tsup",
  "alias": false,
  "peer_metadata": null
}
^8.4.0development
tsx
Environment
{
  "local_name": "tsx",
  "alias": false,
  "peer_metadata": null
}
^4.19.2development
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
^5.7.3development
viem
Environment
{
  "local_name": "viem",
  "alias": false,
  "peer_metadata": null
}
^2.21.26development
vite
Environment
{
  "local_name": "vite",
  "alias": false,
  "peer_metadata": null
}
^6.2.6development
vite-tsconfig-paths
Environment
{
  "local_name": "vite-tsconfig-paths",
  "alias": false,
  "peer_metadata": null
}
^5.1.4development
vitest
Environment
{
  "local_name": "vitest",
  "alias": false,
  "peer_metadata": null
}
^3.0.5development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-+DTMp1cc+NAMW+jSB+p7f1jvbmZ34/q8Km92QQHqhG1fO1DzMI/P91LZnPmV1UVyaPgJpzB3gJFwcPPEinYjNQ==",
  "shasum": "434e772ed4874b29d4877bd506b29a8fa8cc953a",
  "tarball": "https://registry.npmjs.org/@0xcipher0/x402/-/x402-0.6.14.tgz",
  "fileCount": 97,
  "unpackedSize": 13358973,
  "signatures": [
    {
      "keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U",
      "sig": "MEYCIQDVdJJbSNLEEnoJrWNaKG33pjbazMEHxYHG2Wav5nBfGAIhANmkCWp8Y5dSrW9ET2i+ckNPTPTW/JE0DdNfjXjyGtsP"
    }
  ]
}

Repository

PENDING
coinbase/x402

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 23:02 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:fb39fac02465df8546d3717f7430a2f39ed7bcb331aab7de707eb59e33e3474c

Other collected versions

0.6.1225 Oct0.6.1125 Oct0.6.1025 Oct0.6.925 Oct0.6.825 Oct0.6.725 OctView all collected versions →