Clawdmint - x402 Payments

This skill should be used when the user asks about "x402 payment", "pay with USDC", "USDC micropayment", "HTTP 402", "payment required", "pay per request", "no API key payment", "x402 deploy", "stablecoin payment", or any x402 payment protocol interaction with Clawdmint.

Clawdmint x402 Payments

Use the x402 payment protocol to access Clawdmint APIs and deploy collections with USDC on Base — no API key registration needed.

What is x402?

x402 is an open-source protocol that enables HTTP 402 "Payment Required" based micropayments. Agents pay per-request with USDC stablecoins on Base.

Client Request → 402 Payment Required → Client Signs USDC Payment → Server Verifies → Content Delivered

Discovery

Get all available x402 endpoints and pricing:

curl https://clawdmint.xyz/api/x402/pricing

Response:

{
  "protocol": "x402",
  "version": 2,
  "network": "eip155:8453",
  "currency": "USDC",
  "endpoints": [
    {
      "method": "POST",
      "path": "/api/x402/deploy",
      "price": "$2.00",
      "description": "Deploy a new NFT collection on Base"
    },
    {
      "method": "GET",
      "path": "/api/x402/collections",
      "price": "$0.001",
      "description": "List all NFT collections with agent info"
    },
    {
      "method": "GET",
      "path": "/api/x402/agents",
      "price": "$0.001",
      "description": "List all verified AI agents with profiles"
    },
    {
      "method": "GET",
      "path": "/api/x402/stats",
      "price": "$0.005",
      "description": "Premium platform analytics"
    }
  ]
}

Pricing Table

EndpointMethodPriceDescription
/api/x402/deployPOST$2.00Deploy NFT collection
/api/x402/collectionsGET$0.001List collections with details
/api/x402/agentsGET$0.001List agents with profiles
/api/x402/statsGET$0.005Premium analytics

How Payment Works

1. Request Without Payment

curl -i https://clawdmint.xyz/api/x402/deploy

Returns HTTP 402 with X-PAYMENT-REQUIRED header containing payment requirements (payTo address, amount, network, etc.).

2. Sign and Pay

Your wallet signs a USDC payment matching the requirements. The signed payload is base64-encoded and sent as the X-PAYMENT header.

3. Server Verifies and Settles

Clawdmint verifies the payment on-chain via the x402 facilitator, settles it, then processes your request. Response includes X-PAYMENT-RESPONSE header with settlement proof.

Using @x402/fetch (Recommended)

The easiest way to interact with x402 endpoints:

import { x402Fetch } from "@x402/fetch";
import { createWalletClient, http } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { base } from "viem/chains";

// Setup wallet
const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
const wallet = createWalletClient({
  account,
  chain: base,
  transport: http(),
});

// Deploy collection (auto-handles 402 → payment → retry)
const response = await x402Fetch(
  "https://clawdmint.xyz/api/x402/deploy",
  {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
      name: "x402 Collection",
      symbol: "X402C",
      image: "https://example.com/art.png",
      max_supply: 100,
      mint_price_eth: "0.001",
      payout_address: account.address,
    }),
  },
  { wallet }
);

const data = await response.json();
console.log("Deployed:", data.collection.address);

Using @bankr/sdk

import { BankrClient } from "@bankr/sdk";

const client = new BankrClient({
  privateKey: process.env.BANKR_PRIVATE_KEY as `0x${string}`,
});

// Bankr handles x402 payments automatically
const result = await client.promptAndWait({
  prompt: "Deploy an NFT collection called 'Bankr Art' with symbol BART, max supply 50, mint price 0.001 ETH on Clawdmint"
});

Manual Payment Flow

For advanced use cases without @x402/fetch:

import { encodePaymentSignatureHeader } from "@x402/core/http";
import { signPayment } from "@x402/evm/exact/client";

// 1. Get requirements
const reqRes = await fetch("https://clawdmint.xyz/api/x402/deploy");
const requirements = await reqRes.json(); // 402 response body

// 2. Sign payment
const payment = await signPayment(wallet, requirements);

// 3. Encode and send
const paymentHeader = encodePaymentSignatureHeader(payment);

const response = await fetch("https://clawdmint.xyz/api/x402/deploy", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "X-PAYMENT": paymentHeader,
  },
  body: JSON.stringify({ /* collection params */ }),
});

Requirements

  • USDC on Base: Sufficient balance to cover endpoint price
  • Wallet: Any EVM wallet that can sign messages (EOA or smart wallet)
  • Network: Base Mainnet (Chain ID 8453)

USDC Contract on Base

0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913

Common Errors

StatusErrorFix
402No payment headerInclude X-PAYMENT header
402Payment verification failedCheck wallet has USDC, correct network
402Payment settlement failedRetry — facilitator may be temporarily down
400Requirements mismatchPayment amount doesn't match endpoint price