Your Claude Code agent knows what DeFi yields looked like in its training data, not right now. Ask it about HN top stories today and you get nothing useful.
The fix isn't fine-tuning. It's teaching your agent to buy fresh data at runtime.
What is x402?
x402 is a protocol built on HTTP. When an agent hits a payment-gated endpoint, it gets a 402 response with payment terms — price, currency, recipient wallet — plus a free data preview. The agent sends $0.01 in USDC on Base L2, attaches a payment proof header, and gets live data back.
No API keys. No rate limits. No subscriptions. Each call is independently priced.
Step 1: Probe the endpoint
Any asset on ClawMerchants follows the same pattern. Hit it without payment to see what you're getting:
curl https://clawmerchants.com/v1/data/hn-top-stories-live
You get a 402 with a free preview:
{
"status": 402,
"asset": { "id": "hn-top-stories-live", "category": "developer" },
"payment": { "price": "0.01", "currency": "USDC", "chain": "base" },
"preview": {
"sample": [
{ "rank": 1, "title": "Show HN: ...", "score": 342, "comments": 87 }
]
}
}
The preview is free. You only pay for the full dataset.
Step 2: Send USDC on Base
Use the Coinbase SDK or any Base-compatible wallet:
import { Coinbase, Wallet } from "@coinbase/coinbase-sdk";const coinbase = new Coinbase({ apiKeyName: "...", privateKey: "..." });
const wallet = await Wallet.fetch("your-wallet-id");
const transfer = await wallet.createTransfer({
amount: 0.01,
assetId: "usdc",
destination: "0x...", // recipient from the 402 response
network: "base-mainnet"
});
await transfer.wait();
const txHash = transfer.getTransactionHash();
Step 3: Attach payment proof and get data
Base64-encode a JSON object with the tx hash and your wallet, send it in X-PAYMENT:
const paymentProof = Buffer.from(JSON.stringify({
txHash,
buyerWallet: myWalletAddress
})).toString("base64");
const response = await fetch("https://clawmerchants.com/v1/data/hn-top-stories-live", {
headers: {
"X-PAYMENT": paymentProof,
"X-Agent-Id": "my-claude-agent"
}
});
const { data } = await response.json();
// data.stories = live top 10 HN stories, score, comments, URLs
The server verifies the payment on-chain before returning anything.
Wrapping it as a Claude Code tool
The real power is giving Claude Code a tool that handles the full flow autonomously. Create a tool file:
// tools/buy-live-data.ts
export const buyLiveDataTool = {
name: "buy_live_data",
description: `Purchase a live data feed from the ClawMerchants marketplace.
Costs $0.01-$0.05 USDC per request.
Available asset IDs: hn-top-stories-live, defi-yields-live,
token-anomalies-live, security-intel-live, github-trending-live, hf-papers-live`,
inputSchema: {
type: "object" as const,
properties: {
assetId: { type: "string", description: "Asset ID to purchase" }
},
required: ["assetId"]
}
};
export async function executeBuyLiveData(assetId: string) {
// 1. Probe — get payment terms + free preview
const probe = await fetch(`https://clawmerchants.com/v1/data/${assetId}`);
const terms = await probe.json(); // 402 response
// 2. Pay with USDC on Base
const txHash = await sendUsdcPayment(
terms.payment.recipient,
parseFloat(terms.payment.price)
);
// 3. Deliver payment proof
const proof = Buffer.from(JSON.stringify({
txHash,
buyerWallet: MY_WALLET_ADDRESS
})).toString("base64");
const res = await fetch(`https://clawmerchants.com/v1/data/${assetId}`, {
headers: { "X-PAYMENT": proof }
});
return res.json(); // Live data delivered
}
Then in your CLAUDE.md, tell the agent when to use it:
## Live data access
You have a `buy_live_data` tool. Use it when the user asks about real-time data:
- "what's trending on HN?" → buy_live_data("hn-top-stories-live")
- "best DeFi yields right now" → buy_live_data("defi-yields-live")
- "any token price anomalies?" → buy_live_data("token-anomalies-live")
- "latest security CVEs" → buy_live_data("security-intel-live")
Each call costs ~$0.01. Always probe first to check the preview before paying.
Now your agent can discover, evaluate, and purchase data autonomously — no human in the loop for each lookup.
Available live feeds
| Asset ID | Price | Updates every |
|---|---|---|
hn-top-stories-live |
$0.01 | 5 min |
defi-yields-live |
$0.01 | 5 min |
token-anomalies-live |
$0.01 | 5 min |
security-intel-live |
$0.02 | 30 min |
github-trending-live |
$0.01 | 1 hr |
hf-papers-live |
$0.01 | 1 hr |
crypto-sentiment-live |
$0.01 | 5 min |
ai-ecosystem-intel-live |
$0.02 | 1 hr |
Browse the full catalog: clawmerchants.com
Skills (SKILL.md behavioral protocols for code review, security audits, DeFi strategy) are also available if you want to give agents structured decision frameworks instead of raw data.
Why micropayments beat API keys
Free API keys get leaked, scraped, and rate-limited. x402 creates per-request access:
- No key rotation or storage
- Agent evaluates the preview before paying — no surprises
- Pay only for what you use
- Works from any HTTP client
- The payment is proof of intent — bots that pay $0.01 per call are different from bots that hammer free endpoints
More in this series:
- How agent commerce actually works: x402, SKILL.md, and the $0.01 transaction
- How Cursor background agents can buy live data with x402
Install these skills in Claude Code
If you're using Claude Code, Cursor, or any SKILL.md-compatible agent, you can install ClawMerchants skills directly:
# Install all ClawMerchants skills
npx skills add danielxri/clawmerchants
# Or install specific skills
npx skills add danielxri/clawmerchants --skill agent-security-audit-skill
npx skills add danielxri/clawmerchants --skill code-review-skill
npx skills add danielxri/clawmerchants --skill agent-testing-eval-skill
npx skills add danielxri/clawmerchants --skill agent-workflow-automation-skill
npx skills add danielxri/clawmerchants --skill defi-yield-strategy-skill
Installs are tracked on skills.sh automatically. Browse the full asset catalog at clawmerchants.com/browse.
Top comments (0)