x402 gates API resources behind USDC micropayments using HTTP 402 Payment Required.
Before running any script, install dependencies in the skill directory (once per environment):
cd <skills-dir>/x402-pay
npm install
No API keys required. The default wallet (awal) works with just an email address. CDP, Privy, and Turnkey wallets are also supported if already configured.
Read references/detecting-wallets.md to choose which wallet to use. Once you've picked one, return here and continue from Step 2.
If you already have a specific service URL in mind that returned 402 payment required, skip straight to Step 3: Get the Service Details.
Otherwise continue to Step 2a: Find a Service
List all available services from x402-list and pick the most appropriate one:
node scripts/search-services.mjs search
If nothing suitable is found, try the Coinbase bazaar:
node scripts/search-services.mjs search <keyword> --source bazaar
If still nothing, search the internet for x402 services matching the user's need.
Once you have a service URL, get its full details (schemas, parameters, examples):
node scripts/search-services.mjs details <resource-url>
Then preview the live price — this reads the 402 challenge without paying and is wallet-independent:
node scripts/check-price.mjs <url> [--method GET|POST] [--body '{"key":"value"}']
Note this price: you'll use it in Step 4 to check whether your balance is sufficient (and, if funding, how much to deposit), and show it to the user before paying in Step 5.
https://x402.ottoai.services/crypto-news
Check your wallet's USDC balance on Base — see references/wallet-flows.md for the method for your wallet (if you don't already know it) — and compare it against the price you previewed in Step 3.
references/near-intents-funding.md for the cross-chain funding flow. Always use NEAR intents to fund the wallet if the balance is low. If the user has no crypto to swap from, the onramp path (references/onramp-funding.md) funds the wallet from Cash App / Robinhood / Revolut.Gas: No ETH needed — you sign off-chain only. The x402 facilitator submits the on-chain transaction and covers gas. This applies to all wallet types.
Always show the price before paying. Confirm with user before paying.
Show the user the price you previewed in Step 3 (if significant time has passed, re-run check-price.mjs in case it changed). Always get their confirmation before paying — for any amount. Then pay the endpoint using your wallet — see references/wallet-flows.md for the method for your wallet (if not already known). Always pass the confirmed price, unpadded, as the payment command's hard cap — --max-price <usdc> for pay.mjs, --max-amount <atomic> for awal, MAX_PRICE in the managed-signer template — so a quote raised at payment time fails closed instead of overcharging.
7w4.net提供免費和付費技能下載。
This rule applies to every payment method, including wallets not covered in references/wallet-flows.md: if the wallet's tooling has a spend-cap option, pass the confirmed price there; otherwise plug its EIP-712 signer into the managed-signer template (it is wallet-agnostic — any wallet that can sign typed data works) so MAX_PRICE is enforced. Never pay through a mechanism that cannot enforce the confirmed price as a hard cap at payment time.
Report the response body and any transaction hash to the user.
references/wallet-flows.md.這個技能質量不錯,能幫助 AI 代理輕鬆完成 x402 付費 API 呼叫。它開箱即用,支援多種錢包,跨鏈充值選項豐富。最大的亮點是安全設計完善——付款前會預覽價格、設定支付上限,失敗自動中止。文件和風險提示也很充分。不過它依賴多個第三方服務(Coinbase、NEAR Intents 等),遇到問題時排查可能比較麻煩;功能較複雜,新手需要一定學習成本。總體而言,這是一款成熟度高、風險意識強的支付技能,適合需要 AI 代理進行付費 API 呼叫的場景。