Specification
Skill ID
starchild-ai-agent/official-skills/x402
Publisher
starchild-ai-agent
Repository
official-skills
Installs
0
Files
31
Synced
Sep 23, 2026
How to use it

Open any RiverX project, open the Skills panel in the chat, and search for this identifier. The files are fetched from the source repository at install time.

starchild-ai-agent/official-skills/x402Installs these files
  • SKILL.md
  • bazaar.py
  • client.py
  • gateway/app.py
  • gateway/ledger.py
  • gateway/platform_modes.py
  • logo.png
  • references/buying-advanced.md
  • references/selling.md
  • references/troubleshooting.md
  • scripts/buy.py
  • scripts/discover.py
  • scripts/ensure_env.sh
  • scripts/keepalive.sh
  • scripts/make_public.py
  • scripts/monetize.py
  • scripts/preflight.py
  • scripts/verify_setup.py
  • setup.sh
  • templates/lifetime.json
  • templates/metered.json
  • templates/monthly.json
  • templates/multi_plan.json
  • templates/pay_per_use.json
  • templates/payperuse.json
  • templates/prepaid.json
  • templates/quarterly.json
  • templates/subscription.json
  • templates/timepass.json
  • templates/weekly.json
  • templates/yearly.json

What this skill tells the agent

💸 x402 Monetization Skill

Turn any local HTTP service into a paid service on platform networks (Base + Monad + Robinhood + X Layer; x402 V2 protocol, exact scheme, USDC/USDG via EIP-3009 — buyer pays zero gas), and act as a buyer paying other agents' x402 services with the user's Privy wallet.

Architecture: reverse-proxy sidecar. The gateway (gateway/app.py) sits in front of the user's untouched service. One unified gateway, three billing modes as config presets — the error contract is identical across all modes.

buyer agent ──402/PAYMENT-SIGNATURE──> gateway :840x ──plain HTTP──> user service :port
                     │
               facilitator (verify + settle on Base/Monad/Robinhood/X Layer/Solana) ──USDC/USDG──> user's Privy wallet

Reference files (MUST read before the matching task)

Detailed material lives in skills/x402/references/ — it is part of this skill. Do NOT guess or improvise what these files cover:

Before you…MUST first read_file
deploy ANY selling mode beyond basic pay_per_use (full commands, prepaid & multi-plan contracts, admin tokens, templates, gateway lifecycle, always-on/update-mode)skills/x402/references/selling.md
enable / debug / explain limited-time free promotion (amount=0, no settle, P1–P5 ACL, buyer free flow, resource isolation, verify matrix)skills/x402/references/selling.md → Limited-time free promotion
free-promo errors (still charged, upstream 401, amount not 0, wrong service unlocked)skills/x402/references/troubleshooting.md → Limited-time free promotion
debug ANY other error (facilitator verify errors, error contract, security model, port ownership, proxy)skills/x402/references/troubleshooting.md
use the session EOA signer, fund a buyer wallet, or pay on a non-Base-USDC chain/tokenskills/x402/references/buying-advanced.md

Limited-time free promotion (seller quick rules)

For a listed paid marketplace service the owner can open a free window (max 90 days). Full playbook: references/selling.md → Limited-time free promotion.

Agent MUST:

  1. Not blind-PUT free-promo from a UI prompt — run P1–P5 self-check first.
  2. Remember free = wallet identity + amount 0 verify + no settle/debit, not anonymous and not a free lifetime subscription after the window.
  3. On platform gateway: amount-0 challenge and skip settle/debit are built-in.
  4. On custom upstream keys (P3/P4) or self-built x402: you MUST patch ACL / force amount="0" / skip settle — see selling.md Step C.
  5. Use x402 `resource` (path) for access isolation — never invent service_id on the wire.
  6. After enable: verify free-status, 402 amount=0, free call without settlement, then confirm paid path returns after cancel/expiry.

Buyer tip: if unpaid 402 shows accepts[].amount == "0", sign 0 (no USDC needed); do not force list-price signing during free.

Sell — monetize a service (quick start)

FAC=https://starchild-x402-facilitator.fly.dev
# pay_per_use: verify -> settle on EVERY request (simplest mode)
# --networks defaults to "all" (Base + Monad + Robinhood + X Layer + Solana mainnet); the 402 challenge
# returns a multi-accepts list — the buyer picks one chain per payment.
python3 skills/x402/scripts/monetize.py --name my-api --upstream-port 5173 \
    --mode pay_per_use --price 0.01 --facilitator $FAC

# lock to a single chain (custom)
python3 skills/x402/scripts/monetize.py --name my-api --upstream-port 5173 \
    --mode pay_per_use --price 0.01 --networks eip155:8453 --facilitator $FAC

Platform modes follow the community-gateway billing contract: 402 JSON body with accepts as a list (multi-accepts, one entry per network — the buyer picks one chain per payment), accepts[].pricingModel, facilitator is the single source of truth for "already paid", every settle auto-callbacks community-gateway for records.

Billing mode decision table

ModeTierBuyer UXWhen
pay_per_useplatformX-PAYMENT each request, settled every callsimple data endpoints, agent-to-agent one-shots
lifetimeplatformpay once, permanent access (facilitator-verified)one-time unlock, buyout pricing
monthlyplatformpay once per natural monthSaaS-style subscriptions
weekly / quarterly / yearlyplatformfixed-length pass: 7 / 90 / 365 days from newest paymentshort trials, annual discounts
prepaidplatformone on-chain deposit → off-chain debit per callhigh-frequency / sub-cent / usage-metered APIs
payperuselegacySDK V2 headers, pay per requestpre-2.0 deployments
subscriptionextendedx402 top-up → API key + N credits, 1 credit/callprepaid credits, avoids per-call payment latency
meteredextendedlike subscription, route-weighted unitsmixed cheap/expensive endpoints (LLM calls etc.)
timepassextendedx402 payment → N-day pass on an API keyfixed-duration passes (non-natural-month)

⚠️ lifetime/monthly/weekly/quarterly/yearly REQUIRE --facilitator-admin-token (fail-closed at startup). Multi-plan: --plan MODE=PRICE (repeatable). → MUST read `references/selling.md` BEFORE deploying any of these modes — it has the exact commands, contract details, and template list.

Output includes gateway_port. Expose the GATEWAY port, not the upstream (via preview or community-publish). pay_to defaults to the user's Privy EVM wallet — revenue lands there directly. Registry: /data/workspace/.x402/services.json; per-service config/log/state: /data/workspace/.x402/<name>/.

Networks & facilitators

The platform supports multiple chains. By default a service follows the platform mainnet full set (--networks all, the default) — currently Base + Monad + Robinhood + X Layer + Solana. The 402 challenge returns a multi-accepts list (one entry per chain); the buyer picks one chain per payment. Lock to specific chains with --networks eip155:8453,eip155:143,eip155:4663,eip155:196 (custom).

NetworkCAIP-2StablecoinEIP-712 nameGas
Base mainneteip155:8453USDC 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913USD CoinETH (platform-paid)
Base Sepolia (testnet)eip155:84532USDC 0x036CbD53842c5426634e7929541eC2318f3dCF7eUSDCETH (platform-paid)
Monad mainneteip155:143USDC 0x754704bc059f8c67012fed69bc8a327a5aafb603USDCMON (platform-paid)
Monad testneteip155:10143USDC 0x534b2f3A21130d7a60830c2Df862319e593943A3USDCMON (platform-paid)
Robinhood mainneteip155:4663USDG 0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168Global DollarETH (platform-paid)
Robinhood testneteip155:46630USDG 0x7E955252E15c84f5768B83c41a71F9eba181802FGlobal DollarETH (platform-paid)
X Layer mainneteip155:196USDC 0x74b7F16337b8972027F6196A17a631aC6dE26d22USD CoinOKB (platform-paid)
X Layer testneteip155:1952USDC 0x74b7F16337b8972027F6196A17a631aC6dE26d22USD CoinOKB (platform-paid)
FacilitatorNetworksWhen
platform (https://starchild-x402-facilitator.fly.dev, the default for mainnet; override via X402_FACILITATOR_URL or --facilitator)Base + Monad + Robinhood + X Layer + Solana mainnetproduction — platform settler pays gas on every chain
https://x402.org/facilitator (default for testnet)Base Sepolia + Monad + Robinhood + X Layer testnettesting only — REJECTED for mainnet (startup guard)

The platform facilitator handles /verify + /settle on every supported chain; its settler key only pays gas — fund flow is fixed by the buyer's signature and can never touch user funds. **Gas/fees are paid by the platform on every chain

Use this skill in a project

Open any RiverX project, search the Skills panel for starchild-ai-agent/official-skills/x402, and install it in one click.

Use this skill