🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

pch-x402-client

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pch-x402-client

Agent-side SDK to sign EIP-712 x402 debit authorizations from a wallet and submit paid calls to any x402 facilitator.

latest
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

pch-x402-client (agent SDK)

Agent-side SDK to sign EIP-712 x402 debit authorizations from a wallet and submit paid calls to any x402 gateway (PCH or third-party). Includes the canonical EIP-712 schema, the X-PAYMENT-AUTHORIZATION header builder, and retrying submission.

Phase E E.2 greenfield skeleton (worktree-e). DRAFT, NOT PUBLISHED. The JS core is tested, including an EIP-712 round-trip verified against the C.5 testnet escrow domain separator. The Python port is a skeleton pending the Phase E full build. Source is fully readable in this package (Principle 13); links resolve to https://pathcoursehealth.com.

JS usage

const { ethers } = require('ethers');
const c = require('pch-x402-client');

const signer = new ethers.Wallet(PRIVATE_KEY);            // the agent wallet
const domain = { name: 'PCHEscrow', version: '1', chainId: 8453, verifyingContract: ESCROW_ADDRESS };

const url  = c.canonicalUrl('https://gateway.pathcoursehealth.com', '/v1/chat/completions');
const body = JSON.stringify({ model: 'pch-fast', messages: [{ role: 'user', content: 'hi' }] });
const requestHash = c.computeRequestHash('POST', url, body);

const auth   = await c.signDebitAuthorization(signer, domain, { amount: '440', nonce: '0', requestHash, expiry });
const header = c.buildPaymentAuthorizationHeader(auth);
const res    = await c.submit(url, body, header);          // retries 429 / 5xx

EIP-712 schema (frozen at the contract deployment block)

DebitAuthorization(address wallet,uint256 amount,uint256 nonce,bytes32 requestHash,uint256 expiry)
WithdrawalAuthorization(address wallet,uint256 amount,uint256 nonce,uint256 expiry)

Network-agnostic: pass the domain (chainId + verifyingContract) from the seller's agent card / x402-discovery document. No network is hardcoded in the package.

Test

npm test   # node test/signer.test.js  (includes the C.5 testnet domain-separator round-trip)

Status

Greenfield skeleton. Not on npm/PyPI. Publication is a Phase E hard stop.

FAQs

Package last updated on 25 Jul 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts