The official TypeScript/JavaScript SDK for the PayNode Protocol. PayNode is a stateless, non-custodial M2M payment gateway that standardizes the HTTP 402 "Payment Required" flow for AI Agents, settling instantly in USDC on Base L2.
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();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
Built for the Autonomous AI Economy by PayNodeLabs.