Quickstart

Make your first autonomous agent payment in 5 minutes using the x402 protocol.

Prerequisites

  • Node.js 18 or higher

  • A wallet with USDC on Base, Polygon, Solana, or Stellar

  • Basic understanding of stablecoin payments

Install the SDK

npm install @clawd402/openclaw-plugin

Or for Python:

pip install clawd402-python openclaw

Setup your agent wallet

Create a wallet configuration file ~/.clawd402/wallet.json:

{
  "type": "keystore",
  "path": "~/.clawd402/keystore.json",
  "chains": ["base", "polygon", "solana"]
}

Security Note: For production, use hardware wallets (Ledger/Trezor). Never commit private keys to version control.

Configure approval policies

Create ~/.clawd402/policies.yaml:

Make your first payment

TypeScript/JavaScript

Python

What just happened?

When the agent attempts to access the API:

  1. HTTP 402 Discovery: API responds with 402 Payment Required and payment details in headers

  2. Payment Construction: Clawd402 constructs a USDC transaction on Base chain

  3. Policy Check: Verifies payment is within auto-approval limits ($5 < $10)

  4. Blockchain Settlement: Submits transaction and waits for confirmation (~2 seconds)

  5. Request Retry: Retries API request with payment proof, receives data

Total time: ~3 seconds (vs 2-3 days for traditional payments) Total cost: ~$0.03 (vs 3% credit card fee = $0.15)

Receive payments as an agent

Agents can also earn revenue by providing services:

Check payment history

Subscribe to recurring services

Multi-chain payments

Clawd402 automatically selects the optimal chain based on cost and availability:

What's next?

Now that you've made your first payment, explore advanced features:

Get testnet USDC

Need testnet tokens for testing? Use the Base Sepolia faucet:

Or use Clawd402's testnet helper:

Troubleshooting

"Insufficient funds" error

Check your USDC balance on the target chain:

Fund your wallet via:

Payment stuck/pending

Check payment status:

Payments on Base typically confirm in 2-4 seconds. If stuck >30 seconds:

  1. Check network status: status.base.orgarrow-up-right

  2. Verify sufficient gas (ETH on Base/Polygon, SOL on Solana)

  3. Try alternative chain via fallback configuration

"Policy rejected" error

Payment exceeded approval limits. Options:

  1. Approve manually if amount is legitimate

  2. Adjust policy limits in ~/.clawd402/policies.yaml

  3. Use human-in-the-loop approval for this transaction

HTTP 402 not supported by API

Not all APIs support x402 yet. Check if the API provider:

  • Returns 402 Payment Required status code

  • Includes X-Payment-Address and X-Payment-Amount headers

  • Accepts payment proof in retry request

If API doesn't support x402, you can:

  • Request x402 support from API provider

  • Use traditional payment methods for that API

  • Build custom integration wrapper

Support

Questions? We're here to help:

Last updated