- Skill ID
- starchild-ai-agent/official-skills/x402
- Publisher
- starchild-ai-agent
- Repository
- official-skills
- Installs
- 0
- Files
- 31
- Synced
- Sep 23, 2026
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 walletReference 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/token | skills/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:
- Not blind-PUT free-promo from a UI prompt — run P1–P5 self-check first.
- Remember free = wallet identity + amount 0 verify + no settle/debit, not anonymous and not a free lifetime subscription after the window.
- On platform gateway: amount-0 challenge and skip settle/debit are built-in.
- On custom upstream keys (P3/P4) or self-built x402: you MUST patch ACL / force
amount="0"/ skip settle — see selling.md Step C. - Use x402 `resource` (path) for access isolation — never invent
service_idon the wire. - 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 $FACPlatform 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
| Mode | Tier | Buyer UX | When |
|---|---|---|---|
pay_per_use | platform | X-PAYMENT each request, settled every call | simple data endpoints, agent-to-agent one-shots |
lifetime | platform | pay once, permanent access (facilitator-verified) | one-time unlock, buyout pricing |
monthly | platform | pay once per natural month | SaaS-style subscriptions |
weekly / quarterly / yearly | platform | fixed-length pass: 7 / 90 / 365 days from newest payment | short trials, annual discounts |
prepaid | platform | one on-chain deposit → off-chain debit per call | high-frequency / sub-cent / usage-metered APIs |
payperuse | legacy | SDK V2 headers, pay per request | pre-2.0 deployments |
subscription | extended | x402 top-up → API key + N credits, 1 credit/call | prepaid credits, avoids per-call payment latency |
metered | extended | like subscription, route-weighted units | mixed cheap/expensive endpoints (LLM calls etc.) |
timepass | extended | x402 payment → N-day pass on an API key | fixed-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).
| Network | CAIP-2 | Stablecoin | EIP-712 name | Gas |
|---|---|---|---|---|
| Base mainnet | eip155:8453 | USDC 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 | USD Coin | ETH (platform-paid) |
| Base Sepolia (testnet) | eip155:84532 | USDC 0x036CbD53842c5426634e7929541eC2318f3dCF7e | USDC | ETH (platform-paid) |
| Monad mainnet | eip155:143 | USDC 0x754704bc059f8c67012fed69bc8a327a5aafb603 | USDC | MON (platform-paid) |
| Monad testnet | eip155:10143 | USDC 0x534b2f3A21130d7a60830c2Df862319e593943A3 | USDC | MON (platform-paid) |
| Robinhood mainnet | eip155:4663 | USDG 0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168 | Global Dollar | ETH (platform-paid) |
| Robinhood testnet | eip155:46630 | USDG 0x7E955252E15c84f5768B83c41a71F9eba181802F | Global Dollar | ETH (platform-paid) |
| X Layer mainnet | eip155:196 | USDC 0x74b7F16337b8972027F6196A17a631aC6dE26d22 | USD Coin | OKB (platform-paid) |
| X Layer testnet | eip155:1952 | USDC 0x74b7F16337b8972027F6196A17a631aC6dE26d22 | USD Coin | OKB (platform-paid) |
| Facilitator | Networks | When |
|---|---|---|
platform (https://starchild-x402-facilitator.fly.dev, the default for mainnet; override via X402_FACILITATOR_URL or --facilitator) | Base + Monad + Robinhood + X Layer + Solana mainnet | production — platform settler pays gas on every chain |
https://x402.org/facilitator (default for testnet) | Base Sepolia + Monad + Robinhood + X Layer testnet | testing 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
More from starchild-ai-agent
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.
