second-state/x402/x402-payment

Claude Code and agent skill by second-state/x402

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Pay x402-compatible URLs by opening a local browser page for MetaMask signing. Use when a URL returns HTTP 402 or when you know a URL requires x402 payment.

Install

npx vskill@latest install second-state/x402/x402-payment

SKILL.md

x402 Payment Skill

When you need to access a URL that requires x402 payment (HTTP 402 Payment Required), use this skill to handle the full payment flow. The script opens a temporary browser page for the user to sign the payment with MetaMask, then retries the request with the signed payment header.

When to Use

  • A URL returns HTTP 402 Payment Required
  • The user asks you to pay for / access an x402-gated resource
  • The user provides a URL that you know requires x402 payment

How to Invoke

Run the payment script using Bash:

bash
python3 SKILL_DIR/x402_pay.py <url> [--method METHOD] [--body '{"key":"value"}'] [--headers '{"Authorization":"Bearer xxx"}'] [--timeout 120]

Replace SKILL_DIR with the absolute path to this skill's directory.

Arguments
ArgumentDefaultDescription
url(required)The x402-compatible URL to call
--methodGETHTTP method
--bodynoneRequest body as JSON string
--headersnoneAdditional HTTP headers as JSON string
--timeout120Seconds to wait for MetaMask signing
--port18402Preferred port for the local signing server
--networknoneFilter payment options by network (e.g. eip155:84532 for Base Sepolia)
--cheapestoffAuto-select the cheapest standard payment option (excludes batched/gateway schemes)

What Happens

  1. The script calls the target URL
  2. If no 402 → returns the response directly (no payment needed)
  3. If 402 → opens a browser page showing payment details (amount, token, chain)
  4. User signs the payment in MetaMask
  5. Script retries the URL with the signed payment header
  6. Returns the final API response

The user must have MetaMask installed in their browser with a funded wallet.

Reading the Output

The script outputs a single JSON line to stdout:

Success (payment completed)
json
{
"success": true,
"status_code": 200,
"url": "https://api.example.com/endpoint",
"body": "response from the paid API",
"payment_header": "base64-encoded-payment"
}
Success (no payment needed)
json
{
"success": true,
"status_code": 200,
"url": "https://api.example.com/endpoint",
"body": "response body"
}
Failure
json
{
"success": false,
"error": "Payment signing timed out after 120 seconds",
"url": "https://api.example.com/endpoint"
}

Error Scenarios

  • Timeout: User did not complete signing within the timeout period
  • User rejection: User clicked Reject in MetaMask (will show as timeout or error)
  • API error after payment: success will be false, check status_code and body
  • MetaMask not installed: Script will time out; stderr will note the browser was opened

Example

bash
# Pay for an x402-gated API
python3 /path/to/skills/x402-payment/x402_pay.py https://api.example.com/paid-resource
# POST with body and custom headers
python3 /path/to/skills/x402-payment/x402_pay.py https://api.example.com/paid-resource \
--method POST \
--body '{"query": "hello"}' \
--headers '{"X-Custom": "value"}'
# Pick the cheapest Base Sepolia option (useful when a service offers multiple tiers)
python3 /path/to/skills/x402-payment/x402_pay.py https://x402.quicknode.com/base-sepolia/ \
--method POST \
--body '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' \
--network "eip155:84532" --cheapest

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/second-state/x402/x402-payment/badge)](https://verified-skill.com/skills/second-state/x402/x402-payment)

Something wrong with this skill or its page? Tell us.