z402-client
v0.1.0
Published
Client SDK for Zero Trust x402 protocol
Maintainers
Readme
z402-client
Minimal client helper for services that require Z402 payment authentication.
Automatically:
- Detects
402 Payment Requiredresponses - Builds + signs SOL / SPL transfers
- Resends request with
x-paymentheader
Install
npm install z402-clientUsage
import { Z402Client } from "z402-client";
import { Connection, clusterApiUrl, Keypair } from "@solana/web3.js";
const connection = new Connection(clusterApiUrl("devnet"));
const wallet = {
publicKey: keypair.publicKey,
signTransaction: (tx) => connection.sendTransaction(tx, [keypair]),
};
const client = new Z402Client({ connection, wallet });
const res = await client.get("http://localhost:3000/paid", {}, {
computeUnits: 300_000,
priorityMicroLamports: 200_000,
});
console.log(await res.text());
