The official TypeScript/JavaScript SDK for the PayNode Protocol (v2.2.1). PayNode is a stateless, non-custodial M2M payment gateway that standardizes the HTTP 402 "Payment Required" flow for AI Agents, with support for both on-chain receipts and off-chain signatures (EIP-3009).
For complete installation guides, advanced usage, API references, and architecture details, please visit our official documentation: 👉 docs.paynode.dev
npm install @paynodelabs/sdk-js ethersimport { PayNodeAgentClient } from "@paynodelabs/sdk-js";
const client = new PayNodeAgentClient("YOUR_AGENT_PRIVATE_KEY", ["https://mainnet.base.org", "https://rpc.ankr.com/base"]);
async function main() {
// Automatically handles 402 challenges, pays USDC, and retries the request
const response = await client.requestGate("https://api.merchant.com/premium-data");
console.log(await response.text());
}
main();- Zero-Wait Checkout: API response speed drops from 5 seconds to under 50ms by using local signatures instead of waiting for on-chain inclusion.
- Double-Spend Protection:
- L1 (Memory): High-speed local replay protection via
IdempotencyStore. - L2 (RPC): Real-time on-chain
authorizationStateverification.
- L1 (Memory): High-speed local replay protection via
- Empty-Wallet Proof: Integrated
balanceOfprobes to block malicious agents using empty wallets to generate valid signatures. - EIP-3009 Support: Sign payments off-chain using
TransferWithAuthorization. - X402 V2 Protocol: JSON-based handshake for structured agent interaction.
- Dual Flow: Automatic switch between V1 (on-chain receipts) and V2 (off-chain signatures).
- TRON Support: USDT (TRC-20) payment integration.
- Solana Support: SPL USDC/USDT payment integration.
- Cross-chain: Universal settlement via bridges.
The SDK includes a full merchant/agent demonstration in the examples/ directory.
cp .env.example .env
# Edit .env with your PRIVATE_KEY and RPC_URLIf you're testing on Sepolia, run the helper script to mint 1,000 mock USDC:
npx ts-node examples/mint-test-tokens.tsnpx ts-node examples/express-server.tsIn another terminal:
npx ts-node examples/agent-client.tsThe demo will perform a full loop: 402 Handshake -> On-chain Payment -> 200 Verification.
To publish a new version of the SDK:
- Build the project:
npm run build
- Login to NPM (if not already):
npm login
- Publish:
npm publish --access public
PayNode uses two distinct versioning schemes:
| Version Type | Description | Current Value |
|---|---|---|
| Protocol Version | On-chain contracts & core x402 data schema. | 1.4.0 |
| SDK/Product Version | Software package version (npm/SemVer). | 2.2.2 |
Note
Protocol Version changes imply breaking changes in verification or contract interfaces. SDK Version changes may include features, fixes, or performance improvements without altering protocol logic.
Built for the Autonomous AI Economy by PayNodeLabs.