monetize-serviceद्वारा coinbase

Deploy a paid API endpoint that other agents can discover and pay for via x402 protocol. Charges USDC per request on Base using HTTP 402 payment protocol; clients pay with signed transactions, no API keys or accounts required Automatically registers endpoints with the x402 Bazaar for agent discovery when you declare discovery extensions Supports multiple pricing tiers, wildcard routes, and multiple payment options per endpoint using Express middleware Built on @x402/express and @x402/core...

npx skills add https://github.com/coinbase/agentic-wallet-skills --skill monetize-service

Build an x402 Payment Server

Create an Express server that charges USDC for API access using the x402 payment protocol. Callers pay per-request in USDC on Base — no accounts, API keys, or subscriptions needed. Your service is automatically discoverable by other agents via the x402 Bazaar.

How It Works

x402 is an HTTP-native payment protocol. When a client hits a protected endpoint without paying, the server returns HTTP 402 with payment requirements. The client signs a USDC payment and retries with a payment header. The facilitator verifies and settles the payment, and the server returns the response. Services register with the x402 Bazaar so other agents can discover and pay for them automatically.

Confirm wallet is initialized and authed

npx [email protected] status

If the wallet is not authenticated, refer to the authenticate-wallet skill.

Step 1: Get the Payment Address

Run this to get the wallet address that will receive payments:

npx [email protected] address

Use this address as the payTo value.

Step 2: Set Up the Project

mkdir x402-server && cd x402-server
npm init -y
npm install express @x402/express @x402/core @x402/evm @x402/extensions

Create index.js:

const express = require("express");
const { paymentMiddleware } = require("@x402/express");
const { x402ResourceServer, HTTPFacilitatorClient } = require("@x402/core/server");
const { ExactEvmScheme } = require("@x402/evm/exact/server");

const app = express();
app.use(express.json());

const PAY_TO = "<address from step 1>";

// Create facilitator client and x402 resource server
const facilitator = new HTTPFacilitatorClient({ url: "https://x402.org/facilitator" });
const server = new x402ResourceServer(facilitator);
server.register("eip155:8453", new ExactEvmScheme());

// x402 payment middleware — protects routes below
app.use(
  paymentMiddleware(
    {
      "GET /api/example": {
        accepts: {
          scheme: "exact",
          price: "$0.01",
          network: "eip155:8453",
          payTo: PAY_TO,
        },
        description: "Description of what this endpoint returns",
        mimeType: "application/json",
      },
    },
    server,
  ),
);

// Protected endpoint
app.get("/api/example", (req, res) => {
  res.json({ data: "This costs $0.01 per request" });
});

app.listen(3000, () => console.log("Server running on port 3000"));

Step 3: Run It

node index.js

Test with curl — you should get a 402 response with payment requirements:

curl -i http://localhost:3000/api/example

API Reference

paymentMiddleware(routes, server)

Creates Express middleware that enforces x402 payments.

ParameterTypeDescription
routesobjectRoute config mapping route patterns to payment config
serverx402ResourceServerPre-configured x402 resource server instance

x402ResourceServer

Created with a facilitator client. Register payment schemes and extensions before passing to middleware.

const { x402ResourceServer, HTTPFacilitatorClient } = require("@x402/core/server");
const { ExactEvmScheme } = require("@x402/evm/exact/server");

const facilitator = new HTTPFacilitatorClient({ url: "https://x402.org" });
const server = new x402ResourceServer(facilitator);
server.register("eip155:8453", new ExactEvmScheme());
MethodDescription
register(network, scheme)Register a payment scheme for a CAIP-2 network identifier

Route Config

Each key in the routes object is "METHOD /path". The value is a config object:

{
  "GET /api/data": {
    accepts: {
      scheme: "exact",
      price: "$0.05",
      network: "eip155:8453",
      payTo: "0x...",
    },
    description: "Human-readable description of the endpoint",
    mimeType: "application/json",
    extensions: {
      ...declareDiscoveryExtension({
        output: {
          example: { result: "example response" },
          schema: {
            properties: {
              result: { type: "string" },
            },
          },
        },
      }),
    },
  },
}

Accepts Config Fields

The accepts field can be a single object or an array (for multiple payment options):

FieldTypeDescription
schemestringPayment scheme: "exact"
pricestringUSDC price (e.g. "$0.01", "$1.00")
networkstringCAIP-2 network identifier (e.g. "eip155:8453")
payTostringEthereum address (0x...) to receive USDC payments

Route-Level Fields

FieldTypeDescription
acceptsobject or arrayPayment requirements (single or multiple)
descriptionstring?What this endpoint does (shown to clients)
mimeTypestring?MIME type of the response
extensionsobject?Extensions config (e.g. Bazaar discovery)

Discovery Extension

The declareDiscoveryExtension function registers your endpoint with the x402 Bazaar so other agents can discover it:

const { declareDiscoveryExtension } = require("@x402/extensions/bazaar");

extensions: {
  ...declareDiscoveryExtension({
    output: {
      example: { /* example response body */ },
      schema: {
        properties: {
          /* JSON schema of the response */
        },
      },
    },
  }),
}
FieldTypeDescription
output.exampleobjectExample response body for the endpoint
output.schemaobjectJSON schema describing the response format

Supported Networks

NetworkDescription
eip155:8453Base mainnet (real USDC)
eip155:84532Base Sepolia testnet (test USDC)

Patterns

Multiple endpoints with different prices

app.use(
  paymentMiddleware(
    {
      "GET /api/cheap": {
        accepts: {
          scheme: "exact",
          price: "$0.001",
          network: "eip155:8453",
          payTo: PAY_TO,
        },
        description: "Inexpensive data lookup",
      },
      "GET /api/expensive": {
        accepts: {
          scheme: "exact",
          price: "$1.00",
          network: "eip155:8453",
          payTo: PAY_TO,
        },
        description: "Premium data access",
      },
      "POST /api/query": {
        accepts: {
          scheme: "exact",
          price: "$0.25",
          network: "eip155:8453",
          payTo: PAY_TO,
        },
        description: "Run a custom query",
      },
    },
    server,
  ),
);

app.get("/api/cheap", (req, res) => { /* ... */ });
app.get("/api/expensive", (req, res) => { /* ... */ });
app.post("/api/query", (req, res) => { /* ... */ });

Wildcard routes

app.use(
  paymentMiddleware(
    {
      "GET /api/*": {
        accepts: {
          scheme: "exact",
          price: "$0.05",
          network: "eip155:8453",
          payTo: PAY_TO,
        },
        description: "API access",
      },
    },
    server,
  ),
);

app.get("/api/users", (req, res) => { /* ... */ });
app.get("/api/posts", (req, res) => { /* ... */ });

Health check (no payment)

Register free endpoints before the payment middleware:

app.get("/health", (req, res) => res.json({ status: "ok" }));

// Payment middleware only applies to routes registered after it
app.use(paymentMiddleware({ /* ... */ }, server));
app.get("/api/data", (req, res) => { /* ... */ });

POST with body and discovery extension

app.use(
  paymentMiddleware(
    {
      "POST /api/analyze": {
        accepts: {
          scheme: "exact",
          price: "$0.10",
          network: "eip155:8453",
          payTo: PAY_TO,
        },
        description: "Analyze text sentiment",
        mimeType: "application/json",
        extensions: {
          ...declareDiscoveryExtension({
            output: {
              example: { sentiment: "positive", score: 0.95 },
              schema: {
                properties: {
                  sentiment: { type: "string" },
                  score: { type: "number" },
                },
              },
            },
          }),
        },
      },
    },
    server,
  ),
);

app.post("/api/analyze", (req, res) => {
  const { text } = req.body;
  // ... your logic
  res.json({ sentiment: "positive", score: 0.95 });
});

Multiple payment options per endpoint

Accept payments on multiple networks for the same endpoint:

"GET /api/data": {
  accepts: [
    {
      scheme: "exact",
      price: "$0.01",
      network: "eip155:8453",
      payTo: EVM_ADDRESS,
    },
    {
      scheme: "exact",
      price: "$0.01",
      network: "eip155:84532",
      payTo: EVM_ADDRESS,
    },
  ],
  description: "Data endpoint accepting Base mainnet or testnet",
}

Using the CDP facilitator (authenticated)

For production use with the Coinbase facilitator (supports mainnet):

npm install @coinbase/x402
const { facilitator } = require("@coinbase/x402");
const { HTTPFacilitatorClient } = require("@x402/core/server");

const facilitatorClient = new HTTPFacilitatorClient(facilitator);
const server = new x402ResourceServer(facilitatorClient);
server.register("eip155:8453", new ExactEvmScheme());

This requires CDP_API_KEY_ID and CDP_API_KEY_SECRET environment variables. Get these from https://portal.cdp.coinbase.com.

Testing with the pay-for-service Skill

Once the server is running, use the pay-for-service skill to test payments:

# Check the endpoint's payment requirements
npx [email protected] x402 details http://localhost:3000/api/example

# Make a paid request
npx [email protected] x402 pay http://localhost:3000/api/example

Pricing Guidelines

Use CaseSuggested Price
Simple data lookup$0.001 - $0.01
API proxy / enrichment$0.01 - $0.10
Compute-heavy query$0.10 - $0.50
AI inference$0.05 - $1.00

Checklist

  • Get wallet address with npx [email protected] address
  • Install express, @x402/express, @x402/core, @x402/evm, and @x402/extensions
  • Create x402ResourceServer with facilitator client and register ExactEvmScheme for eip155:8453
  • Define routes with prices, descriptions, and discovery extensions (Bazaar auto-registers when routes declare it)
  • Register payment middleware before protected routes
  • Keep health/status endpoints before payment middleware
  • Test with curl (should get 402) and npx [email protected] x402 pay (should get 200)
  • Announce your service so other agents can find and use it

coinbase की और Skills

authenticate-wallet
by coinbase
Email OTP-based wallet authentication with validation and status checking. Two-step login flow: initiate with email to receive a 6-digit OTP, then verify with the flowId and code to complete authentication Includes input validation rules for email, flowId, and OTP to prevent shell injection before executing commands Provides status checking, balance queries, address retrieval, and wallet window access via companion CLI commands All commands support --json output for machine-readable...
fund
by coinbase
Deposit USDC to wallet via Coinbase Onramp or direct transfer. Opens a companion UI where users select preset amounts ($10, $20, $50) or custom values and choose from Apple Pay, debit card, bank transfer, or Coinbase account funding Supports multiple payment methods with varying settlement times: instant for card and Apple Pay, 1–3 days for ACH bank transfers Deposits funds as USDC on the Base network; alternatively, users can send USDC directly to the wallet address via npx [email protected]...
pay-for-service
by coinbase
Call paid APIs on Base with automatic USDC payment via x402 protocol. Executes HTTP requests (GET, POST, etc.) to x402-enabled endpoints with atomic USDC payments handled automatically Supports request customization through method, JSON body, query parameters, and custom headers Includes payment controls: set maximum USDC amount per request and group related operations with correlation IDs Requires wallet authentication and sufficient USDC balance; validates all user input to prevent shell...
query-blockchain-data
by coinbase
Query onchain blockchain data on Base using the CDP SQL API via x402. Use when you or your user want to view onchain information about decoded blocks,…
query-onchain-data
by coinbase
Query onchain data on Base using SQL with per-query x402 payments. Access decoded events, transactions, and blocks via CoinbaseQL, a ClickHouse-based SQL dialect supporting joins, CTEs, subqueries, and standard functions Three main tables available: base.events (decoded smart contract logs), base.transactions (full transaction data), and base.blocks (block metadata) Requires filtering on indexed fields ( event_signature , address , block_timestamp ) in event queries to avoid full table...
search-for-service
by coinbase
Search and discover paid API services available on the x402 bazaar marketplace. Query the marketplace using BM25 relevance search, list all available resources, or inspect specific endpoints to see pricing and payment requirements without paying Supports filtering by network (base, base-sepolia) and output formats (human-readable or JSON) Results are cached locally and auto-refresh every 12 hours; no authentication required for any search or discovery operation Use as a fallback when no...
send-usdc
by coinbase
Transfer USDC to Ethereum addresses or ENS names on Base. Accepts both hex addresses (0x...) and ENS names (.eth) as recipients, with automatic ENS resolution Supports flexible amount formats: dollar notation ($5.00), decimal (1.50), or atomic units (1000000) Requires wallet authentication via the authenticate-wallet skill and sufficient USDC balance before sending Includes input validation to prevent shell injection and optional JSON output for programmatic use
trade
by coinbase
Execute token swaps on Base network using flexible amount formats and built-in token aliases. Supports three common token aliases (USDC, ETH, WETH) plus arbitrary contract addresses; amounts can be specified as dollar values, decimals, whole numbers, or atomic units with automatic decimal detection Includes configurable slippage tolerance (in basis points) and JSON output option for programmatic integration Requires wallet authentication via the authenticate-wallet skill; validates all user...

NotebookLM Web Importer

एक क्लिक में वेब पेज और YouTube वीडियो NotebookLM में आयात करें। 200,000+ उपयोगकर्ताओं द्वारा विश्वसनीय।

Chrome एक्सटेंशन इंस्टॉल करें