β‘ Quickstart β 1 Minute to Your First Agent Payment
Get an AI Agent to autonomously pay $0.10 USDC for a premium API request on Base Sepolia.
1. Install
npm install @paynodelabs/sdk-js2. Agent (Payer)
import { PayNodeAgentClient } from '@paynodelabs/sdk-js';
async function main() {
// Now only needs Private Key! (Defaults to Base Mainnet RPCs)
// For Sandbox: new PayNodeAgentClient(key, 'https://sepolia.base.org')
const agent = new PayNodeAgentClient(process.env.PRIVATE_KEY);
// Requests a protected route β 402 payment is handled autonomously
const res = await agent.requestGate('http://localhost:3000/api/data');
const { data } = await res.json();
console.log('β
Received:', data);
}
main();3. Merchant (Receiver)
Protect your API route. Defaults to USDC on Base Mainnet.
import { x402Gate, PAYNODE_ROUTER_ADDRESS_SANDBOX, BASE_USDC_ADDRESS_SANDBOX } from '@paynodelabs/sdk-js';
// 1. Minimum config for Sandbox (Base Sepolia)
app.get('/api/data', x402Gate({
merchantAddress: '0xYOUR_WALLET',
price: '0.10',
chainId: 84532,
contractAddress: PAYNODE_ROUTER_ADDRESS_SANDBOX,
tokenAddress: BASE_USDC_ADDRESS_SANDBOX,
}), (req, res) => {
res.json({ data: 'Hello from AI Economy!' });
});
// 2. Minimum config for Mainnet (Base)
// app.get('/api/data', x402Gate({ merchantAddress: '0x...', price: '1.00' }));π Standard Precision & Limits
PayNode uses the tokenβs smallest unit (USDC = 6 decimals).
| Amount (USDC) | PayNode Unit | Protocol Status |
|---|---|---|
| 0.001 USDC | 1,000 | β Protocol Floor |
| 1.00 USDC | 1,000,000 | β Active |
| < 0.001 USDC | < 1,000 | β Rejected (Dust Protection) |
Next Steps: