Make BSV-authenticated or paid API requests. Use for: BRC-31 auth, 402 payment, BSV micropayments, x402, paid API calls. Requires a BRC-100 wallet (MetaNet Client at localhost:3321, or X402_WALLET_URL).
Ships in x402. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Run a BRC-100 HTTP wallet: MetaNet Client for a person, or the headless
bsv-wallet-cli daemon for an agent with no human. See the repository
README prerequisites for installation and
the wallet README's setup gaps. Set X402_WALLET_URL to the headless daemon's
configured loopback URL. For MetaNet Client at the default URL, check with:
curl -s -H "Origin: http://localhost" http://localhost:3321/isAuthenticated
If the selected wallet is not running, start that wallet. MetaNet Client is available from https://getmetanet.com; headless setup follows the public wallet README.
Choosing the wallet: every wallet call (identity, signatures, createAction, internalizeAction, upload, execute-action) goes to X402_WALLET_URL (default http://localhost:3321). To pay from a second wallet daemon, prefix the command: X402_WALLET_URL=http://localhost:3322 python3 ./scripts/brc31_helpers.py pay .... BRC-31 sessions are cached per (server, wallet identity key), so switching wallets always gets a fresh handshake for the new identity - never the other wallet's session.
$ARGUMENTS
A directory of available agents lives at x402agency.com. Run list to see all registered agents - their names, capabilities, and URLs. Agent names resolve automatically anywhere a URL is expected.
Always start with list when the user's request could match any registered agent. Use the agent descriptions, capabilities, and taglines to match the user's natural language intent to the right agent. Don't assume which agent to use - check the registry.
The registry is cached locally for 5 minutes at ~/.local/share/brc31-sessions/registry.json. Full URLs (https://...) still work directly and bypass the registry.
All operations use the helper script bundled with this skill. All commands output JSON to stdout.
| Command | Purpose |
|---|---|
python3 ./scripts/brc31_helpers.py list | List all agents from the x402agency.com registry |
python3 ./scripts/brc31_helpers.py discover <name_or_url> | Learn server endpoints, auth requirements, costs |
python3 ./scripts/brc31_helpers.py auth <METHOD> <name_or_url> [body] | Authenticated request (no payment) |
python3 ./scripts/brc31_helpers.py pay <METHOD> <name_or_url> [body] | Authenticated + paid request (auto-handles 402) |
python3 ./scripts/brc31_helpers.py retry-payment <saved-file> | Replay a saved payment with the original wallet |
python3 ./scripts/brc31_helpers.py import-refund <saved-file> | Import a saved refund without resending the payment |
python3 ./scripts/brc31_helpers.py upload <file> <name_or_url> [retention_min] [--public-base URL] | UHRP file upload: pays /upload, PUTs the bytes, returns the public URL |
python3 ./scripts/brc31_helpers.py identity | Get wallet's 66-char hex identity key |
python3 ./scripts/brc31_helpers.py execute-action <json> | Execute a pending action template (broadcasts inscription tx after user confirms) |
python3 ./scripts/brc31_helpers.py session <base_url> | Inspect the current wallet's cached session |
Handshake is automatic - never call it manually before auth or pay.
List - Run list to see all registered agents. Match the user's intent to an agent by reading the name, tagline, and capabilities from the registry. There may be many agents - pick the best match.
Discover - Run discover <agent_name> on the matched agent to get its full manifest: endpoints, pricing, input schemas. Present a summary to yourself (or the user if they're exploring).
Route - Match user intent to an endpoint:
auth: true, no payment → use authpayment with satoshis → use pay (do NOT ask user to confirm - consent is implicit by invoking this skill; typical costs are 1-100 sats)auth: false → plain curl, no skill neededCall - Run the appropriate command. For requests with a JSON body, pass it as the 4th argument:
python3 ./scripts/brc31_helpers.py pay POST <agent_name>/<endpoint> '{"key":"value"}'
Present - Parse the JSON response ({status, headers, body}). The body is a string that may contain nested JSON - parse it before presenting.
Action - If the pay response contains pending_action (e.g. from 1sat-agent),
present the cost breakdown to the user and ask for confirmation before calling
execute-action. Do NOT broadcast automatically. The pending_action includes
costs (service fee, estimated mining fee, estimated total) and the action template.
Once the user confirms, run:
python3 ./scripts/brc31_helpers.py execute-action '<action_json>'
The result includes txid and inscription_id.
Use upload with the registry name bsv-storage (the default server).
It pays POST /upload at https://storage.x402agency.com, PUTs the file bytes
to the presigned R2 URL with required headers, and derives the public URL
from the registry-hosted manifest at
https://x402agency.com/manifests/bsv-storage.json. Downloads use
https://files.x402agency.com/cdn/{id}. Pricing is $0.05 per GB-month with a
1,000-sat minimum per upload to cover the overlay advertisement miner fee.
python3 ./scripts/brc31_helpers.py upload ./report.html bsv-storage 525600
# Default server and one-year retention:
python3 ./scripts/brc31_helpers.py upload ./report.html
For another protocol-compatible server without a public URL manifest, pass
its full API URL and --public-base https://your-public-files-domain.
retention_min is the hosting duration in minutes (default 525600 = 1 year).publicURL, objectKey, amountSats, and verified./upload payment rides in the request header.
If the paying wallet funds from coins with large proof BEEFs, the payment
can exceed a GCS-fronted server's ~8KB header cap and return 413. The
command reports this clearly. Cloudflare-hosted UHRP servers accept large
headers; otherwise pay from a wallet with lighter UTXOs.User asks: "generate an image of a sunset"
# Step 1: Check what agents are available
python3 ./scripts/brc31_helpers.py list
# → Returns JSON array. Read taglines/capabilities. Pick the image generation agent.
# Step 2: Discover its endpoints and pricing
python3 ./scripts/brc31_helpers.py discover <matched_agent_name>
# → Returns manifest with endpoints, pricing tiers, input schemas
# Step 3: Call the paid endpoint
python3 ./scripts/brc31_helpers.py pay POST <agent_name>/<endpoint> '{"prompt":"a sunset"}'
# → Handles auth + 402 + payment automatically. Returns result.
python3 ./scripts/brc31_helpers.py discover "https://some-server.example.com"
Returns a manifest with name, serverIdentityKey, endpoints[].
python3 ./scripts/brc31_helpers.py auth POST <agent_name>/<endpoint>
python3 ./scripts/brc31_helpers.py pay POST "https://some-server.example.com/paid"
Servers that support BRC-29 refunds will automatically return refund data when a paid request fails after payment. The client auto-detects and internalizes refunds - no manual action needed.
/paid fails immediately)/status/{id} for async operations that failedThe discover command shows which endpoints support refunds. The pay command output includes a refund block when a refund was received and internalized.
If a paid response is lost, the helper retries the identical payment after 2, 5, and 10 seconds. Signed retryable 503 responses use a separate six-attempt bound and honour Retry-After. Signed 202 and retryable 503 waits are capped at the remaining quote window. Sends must start within the quote's five-minute window; each started request retains its 300-second response timeout. It never creates another payment for that quote. Unresolved calls retain ~/.x402/pending/<txid>.json and print the txid and an exact retry-payment command while the window remains open. Use that command with the original wallet instead of starting another pay call. Signed ERR_PAYMENT_REPLAYED stops retries and removes the already-claimed payment file. Signed ERR_QUOTE_EXPIRED stops retries and retains the file marked expired-unclaimed, with the time, server code and message: the server may not have claimed this payment; the sats are yours if no service was delivered. Keep the file and recover with the server operator through the refund path or a later receipt query, then use import-refund when refund data is available. Local quote expiry also marks and retains the file without a retry command; other unconfirmed responses retain a terminal recovery record. Only signed HTTP 200 for the same payment, claimed replay, or an imported refund removes the pending file. Failed refund imports preserve and return the delivered response and print an import-refund command; use it with the original wallet to import the saved refund without resending the payment.
Payment is sent via x-bsv-payment header as JSON: {"derivationPrefix":"...","derivationSuffix":"...","transaction":"<base64 BEEF>"}. The client handles this automatically.
Transport: Payment normally rides in the x-bsv-payment header. For payments larger than 8KB, the client uses BRC-105 multipart/form-data transport when the server advertises it (x-bsv-payment-transports: multipart on the 402); otherwise it keeps the payment in the header. Typical payments are ~2KB - well under the threshold - so header transport is what's used in practice. (No live x402agency.com agent currently advertises multipart.)
https://poc-server.dev-a3e.workers.devhttp://localhost:8787 (run cd poc-server && npm run dev)Only consult this section if something goes wrong.
| Symptom | Fix |
|---|---|
MetaNet Client not running | Start MetaNet Client app or download from https://getmetanet.com |
| Discovery returns 404 | Server may not have /.well-known/x402-info; proceed with known endpoint info or ask user |
| Connection error | Server may be down or wallet not running |
| Payment error | Tell user to check MetaNet Client for approval prompt; may also be insufficient funds |
| HTTP 401 | Handled automatically - the client clears the stale session, re-handshakes, and retries once. If a 401 still surfaces, the server genuinely rejected auth (not a stale session). |
Signature is not valid on POST | Session may be stale. Clear: python3 ./cli.py session --clear <server_url> |
| Persistent auth failures | Clear session: python3 ./cli.py session --clear <server_url> |
| Need verbose output | Use full CLI: python3 ./cli.py -v auth POST "<url>" |
cli.py (opens in a new tab)lib/CLAUDE.md (opens in a new tab)lib/__init__.py (opens in a new tab)lib/auth_request.py (opens in a new tab)lib/handshake.py (opens in a new tab)lib/headers.py (opens in a new tab)lib/metanet.py (opens in a new tab)lib/nonce.py (opens in a new tab)lib/payment.py (opens in a new tab)lib/refund.py (opens in a new tab)lib/registry.py (opens in a new tab)lib/serialize.py (opens in a new tab)lib/session.py (opens in a new tab)lib/upload.py (opens in a new tab)requirements.txt (opens in a new tab)scripts/brc31_helpers.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
/x402:x402from x402
npx claudepluginhub calgooon/x402 --plugin x402