Setting up x402 payments for MemoClaw — from wallet creation to first paid call


MemoClaw gives every wallet 100 free API calls. No registration, no API keys — your wallet is your identity. But once those 100 calls are gone, your agent needs USDC on Base to keep storing and recalling memories.

This guide walks through the full setup: creating a wallet, funding it, how x402 payments work under the hood, and monitoring your spend so you don’t wake up to surprises.

What gets charged (and what doesn’t)

Before setting up payments, know what costs money. MemoClaw only charges for operations that use OpenAI embeddings or GPT.

Paid operations:

  • Store memory: $0.005
  • Store batch (up to 100): $0.04
  • Recall (semantic search): $0.005
  • Update memory (content change): $0.005
  • Extract/Ingest/Consolidate/Context/Migrate: $0.01

Free operations (always):

  • List, Get, Delete, Bulk Delete
  • Text search, Suggested, Core memories
  • Relations, History, Export
  • Namespaces, Stats

The free endpoints don’t hit OpenAI, so there’s nothing to charge for. Your agent can list, audit, and export memories all day without spending anything.

Step 1: Create or connect a wallet

If you’re running an OpenClaw agent, you likely already have a wallet configured. Check with:

openclaw gateway status

If you see a wallet address, you’re set. If not, you need one. Any Ethereum-compatible wallet works — the requirement is that it can sign EIP-712 typed data for x402 payment authorization.

For OpenClaw agents, the simplest path is letting the gateway manage the wallet. Your agent’s wallet is its identity across all x402-compatible services, not just MemoClaw.

Step 2: Get USDC on Base

MemoClaw accepts USDC on Base (Coinbase’s L2). You need actual USDC tokens at your wallet address on the Base network.

If you already have USDC on another chain:

Bridge it to Base. The official Base Bridge (bridge.base.org) moves USDC from Ethereum mainnet. Third-party bridges like Across or Stargate support transfers from Arbitrum, Optimism, and Polygon.

If you’re starting from scratch:

  1. Buy USDC on any exchange (Coinbase, Kraken, etc.)
  2. Withdraw directly to Base if the exchange supports it (Coinbase does natively)
  3. Or withdraw to Ethereum and bridge to Base

How much do you need?

Do the math on your expected usage. If your agent does 50 store + 50 recall operations per day:

50 stores × $0.005 = $0.25/day
50 recalls × $0.005 = $0.25/day
Total: $0.50/day ≈ $15/month

Start with $5-10 in USDC to test everything, then fund based on actual usage.

Step 3: Verify your setup

Before going to production, confirm the payment pipeline works end-to-end.

# Check your free tier status
memoclaw stats

# Store a test memory (uses a free call if you have any left, or triggers x402)
memoclaw store "Testing x402 payment setup" \
  --importance 0.5 \
  --tags test

# Recall it back
memoclaw recall "payment setup test"

If the store and recall succeed, payments are working. Check your balance:

memoclaw stats

The stats endpoint is free and shows your usage breakdown, remaining free calls, and total spend.

How x402 works under the hood

x402 is an HTTP-native payment protocol. Here’s what happens when your agent makes a paid MemoClaw call:

  1. Agent sends request — a normal HTTP call to api.memoclaw.com
  2. Server responds with 402 — if you’re past the free tier, the API returns HTTP 402 with a payment challenge in the headers
  3. Client signs payment — the MemoClaw CLI/SDK signs an EIP-712 typed data message authorizing the specific amount
  4. Agent retries with payment header — the signed authorization goes in the X-402-Payment header
  5. Server verifies and processes — MemoClaw checks the signature, confirms your USDC balance, executes the transfer, and processes your request

The CLI and SDK handle this transparently. You don’t need to manually construct payment headers.

Agent                    MemoClaw API                Base Network
  |                          |                           |
  |-- POST /store ---------->|                           |
  |<-- 402 + payment terms --|                           |
  |-- POST /store + payment->|                           |
  |                          |-- verify signature ------>|
  |                          |<-- balance confirmed -----|
  |<-- 200 + stored ---------|                           |

The payment is per-request. No subscriptions, no prepaid credits. Your wallet balance is your budget.

Monitoring spend

The stats endpoint is free and gives you everything you need:

memoclaw stats

This returns total calls by type, spend to date, and remaining free-tier calls.

For programmatic monitoring in an OpenClaw agent, build a spend-check into your heartbeat or cron:

# In your agent's periodic check
memoclaw stats --json | jq '.totalSpend'

Set up alerts by checking spend against a threshold:

#!/bin/bash
SPEND=$(memoclaw stats --json | jq -r '.totalSpend')
THRESHOLD=10.00

if (( $(echo "$SPEND > $THRESHOLD" | bc -l) )); then
  echo "MemoClaw spend ($SPEND USDC) exceeded threshold ($THRESHOLD)"
fi

Cost optimization tips

Use free endpoints first. List, text search, stats, export — these never cost anything. Only use recall (semantic search) when you need semantic matching. For exact lookups, text search is free.

Batch your stores. Storing 100 memories individually costs $0.50 (100 × $0.005). A single batch store of 100 costs $0.04. That’s 12x cheaper.

# Instead of 100 individual stores, batch them
memoclaw store-batch memories.json

Use consolidation. Duplicate memories mean duplicate recall hits and wasted embedding costs. Run memoclaw consolidate periodically to merge duplicates. The call costs $0.01 but prevents redundant stores and recalls down the line.

Namespace your recalls. Recalling across all namespaces searches more memories and returns more results. Scoping to a specific namespace reduces the search space.

# Scoped recall — faster, more relevant
memoclaw recall "deployment steps" --namespace ops

Troubleshooting

“Insufficient balance” errors: Your wallet doesn’t have enough USDC on Base. Check your balance on basescan.org or via your wallet. USDC on Ethereum mainnet doesn’t count — it must be on Base.

Transactions failing silently: Check that your wallet can sign EIP-712 messages. Hardware wallets sometimes need explicit approval for typed data signing. The CLI handles this, but custom integrations may need to implement the signing flow.

402 responses not being handled: If you’re using raw HTTP calls instead of the CLI/SDK, you need to implement the x402 handshake yourself. The 402 response includes a X-402-Payment-Required header with the payment terms. Parse it, sign the authorization, and retry with X-402-Payment.

Free tier exhausted unexpectedly: The free tier is 100 calls total, not per day or per month. Once they’re gone, they’re gone. Check memoclaw stats for your usage breakdown.

What it costs in practice

Real numbers for common OpenClaw agent patterns:

PatternDaily callsDaily costMonthly cost
Light personal agent20 store + 30 recall$0.25~$7.50
Active workspace agent50 store + 100 recall$0.75~$22.50
Multi-agent team (shared wallet)200 store + 300 recall$2.50~$75
Heavy cron + heartbeat agent100 store + 200 recall$1.50~$45

These assume individual stores. Batching cuts store costs significantly.

x402 payments mean no subscriptions, no billing portals. Your wallet has USDC, your agent has memory. Run out of USDC, your agent can still use free endpoints — it just can’t store or recall until you top up.

Start with the 100 free calls to validate your memory patterns, then fund your wallet based on actual usage. The stats endpoint is free, so check it early and often.