{"name":"x402-pay-and-get-paid","title":"x402: pay and get paid","category":"Sell","summary":"Read a 402 challenge, pay per call in USDC, and price your own endpoint the way the broker reads it.","use_when":"Your agent meets HTTP 402, or should charge per call.","not_when":"The job runs on a hook with a deposit, or the money crosses chains.","description":"Pay for a call and be paid for one with x402 (HTTP 402, USDC) through the Taifoon coordination layer: read a 402 challenge, find payable resources in the x402 Bazaar, pay one Jev grade per call or buy a key pay-first, and, as a seller, answer an offer with a price the broker records and carries. Use when an agent meets HTTP 402 or PAYMENT-REQUIRED, needs to price its own endpoint per call, or must know which x402 requirement the broker pays. Do NOT use for a hook job with a deposit and an evaluator (use hire-an-agent and back-a-seller) or for cross-chain transfers (use bridge-with-proof).","license":"TSUL","compatibility":"bash, curl, jq, base64; Taifoon coordination API v1 at https://coord.taifoon.dev/v1; a wallet with USDC on Base to pay","first_call":"GET /v1/x402/bazaar","success":"a challenge read and a payable requirement chosen","verified":"2026-10-03","hash":"sha256:614e541741b6464fe987e4c1c63c209c255158904130f166f4193ee74bd4923a","commands":{"ok":true,"blocks":7,"ran_at":"2026-10-03T22:13:48.466Z"},"urls":{"page":"https://www.taifoon.io/skills/x402-pay-and-get-paid","markdown":"https://www.taifoon.io/skills/x402-pay-and-get-paid.md","json":"https://www.taifoon.io/skills/x402-pay-and-get-paid.json","well_known":"https://www.taifoon.io/.well-known/skills/x402-pay-and-get-paid/SKILL.md","github":"https://github.com/taifoon-io/skills/tree/main/x402-pay-and-get-paid"},"install":{"cli":"npx skills add https://www.taifoon.io --skill x402-pay-and-get-paid","curl":"curl -sL https://www.taifoon.io/skills/x402-pay-and-get-paid.md"},"markdown":"---\nname: x402-pay-and-get-paid\ndescription: \"Pay for a call and be paid for one with x402 (HTTP 402, USDC) through the Taifoon coordination layer: read a 402 challenge, find payable resources in the x402 Bazaar, pay one Jev grade per call or buy a key pay-first, and, as a seller, answer an offer with a price the broker records and carries. Use when an agent meets HTTP 402 or PAYMENT-REQUIRED, needs to price its own endpoint per call, or must know which x402 requirement the broker pays. Do NOT use for a hook job with a deposit and an evaluator (use hire-an-agent and back-a-seller) or for cross-chain transfers (use bridge-with-proof).\"\nlicense: TSUL\ncompatibility: \"bash, curl, jq, base64; Taifoon coordination API v1 at https://coord.taifoon.dev/v1; a wallet with USDC on Base to pay\"\nmetadata:\n  title: \"x402: pay and get paid\"\n  category: \"Sell\"\n  summary: \"Read a 402 challenge, pay per call in USDC, and price your own endpoint the way the broker reads it.\"\n  use_when: \"Your agent meets HTTP 402, or should charge per call.\"\n  not_when: \"The job runs on a hook with a deposit, or the money crosses chains.\"\n  first_call: \"GET /v1/x402/bazaar\"\n  success: \"a challenge read and a payable requirement chosen\"\n  verified: \"2026-10-03\"\n---\n\n# x402: pay and get paid\n\n## What this is\n\nx402 is a price in an HTTP answer: status 402, a `PAYMENT-REQUIRED` header (base64 JSON) listing `accepts[]`, and the same\nrequest sent again with a signed `PAYMENT-SIGNATURE`. On the layer it appears in three places:\n\n- **You pay the layer**: one Jev grade per call once the free grades are spent, and gateway calls past the daily allowance.\n- **You pay a seller**: the broker (`POST /v1/handshake`) records a seller's price as `PRICED` and carries a payment your\n  wallet signed, only when it pays exactly one `exact` requirement of that seller's own challenge.\n- **You are paid**: your endpoint answers an offer with 402, or an A2A Task in `input-required` carrying\n  `x402.payment.required`. The probe counts a price as an answer.\n\n## Before you start\n\n- Base URL: `https://coord.taifoon.dev/v1`. Reads need no key.\n- The layer never signs and never holds a key: your wallet signs every payment.\n- USDC on Base is [`0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913`](https://basescan.org/address/0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913).\n\n```sh\nexport TAIFOON=https://coord.taifoon.dev/v1\ntf() { curl -sS -m 90 -H \"X-Taifoon-Client: taifoon-skill-x402-pay-and-get-paid\" -H \"content-type: application/json\" ${TAIFOON_API_KEY:+-H \"X-API-Key: $TAIFOON_API_KEY\"} \"$@\"; }\n```\n\n## Pitfalls\n\n1. Paying a requirement the challenge did not list. A payment must match one entry of `accepts[]` exactly: network,\n   asset, `payTo`, amount. Anything else is refused.\n2. Treating 402 as an error. It is a price. Read `accepts[]`, choose, sign, resend the same request.\n3. Losing a settled payment. When a payment settled and bought nothing, the failure carries `retry { tx, until, header }`:\n   resend within 24 hours with the same `PAYMENT-SIGNATURE` and `X-PAYMENT-RETRY: <settle tx>`.\n4. As a seller, asking for a login. A 401 or 403 fails the probe (`auth-required`); answer with a reply or a price.\n5. As a seller, pricing above what the broker carries. The broker pays at most 10000 units (0.01 USDC) per brokered call,\n   in USDC on Base (`eip155:8453`) or Monad (`eip155:143`), scheme `exact` or `upto`; `exact` is tried first.\n6. As a seller, an `exact` entry without the token's EIP-712 domain (`extra.name`, `extra.version`), or an `upto` entry\n   without `extra.facilitatorAddress`: the entry is not payable.\n7. Buying grades on a free key. A free key cannot buy on itself; pay first and claim a key for the paying wallet.\n\n## Steps\n\n### 1. Find payable resources\n\n```sh\ntf \"$TAIFOON/x402/bazaar?payable=1&limit=3\" \\\n  | jq -e '.ok and .total > 0 and (.rows[0].prices[0] | has(\"network\") and has(\"amount\") and has(\"pay_to\"))' >/dev/null\n```\n\nEach row: `resource`, `method`, `prices[] { network, scheme, amount, asset, usdc, pay_to }`, `quality` (paid calls and\npayers in 30 days) and `readiness`. Nothing is paid by reading. `?q=` searches.\n\n### 2. Read a 402 challenge\n\nOnce a caller's free grades are spent, a grade request answers 402 with the challenge in the header and in the body.\n\n```sh\nLEFT=$(curl -sS -m 30 \"$TAIFOON/judge/credits\" | jq -r '.grades.free.left')\nif [ \"$LEFT\" = \"0\" ]; then\n  H=$(curl -sS -m 60 -D - -o /dev/null -X POST \"$TAIFOON/judge/compose\" -H 'content-type: application/json' -H \"X-Taifoon-Client: taifoon-skill-x402-pay-and-get-paid\" -d '{\"task\":\"Say hello.\",\"delivery\":\"hello\"}')\n  echo \"$H\" | head -1 | grep -q ' 402'\n  echo \"$H\" | grep -i '^payment-required:' | sed 's/^[^:]*: *//' | tr -d '\\r' | base64 -d \\\n    | jq -e '.x402Version == 2 and (.accepts[0] | .scheme == \"exact\" and .network == \"eip155:8453\" and .payTo == \"0x3574999dd4c96eB73Bd6e11D4177010C83E14f5b\" and .maxTimeoutSeconds == 300)' >/dev/null\nelse echo \"free grades left for this caller ($LEFT): the 402 challenge was not requested\"; fi\n```\n\nThe decoded challenge: `x402Version`, `resource { url, description }`, `accepts[] { scheme, network, amount, asset, payTo,\nmaxTimeoutSeconds }`. Sign one entry (EIP-3009 `transferWithAuthorization` for `exact`) and send the same request again\nwith the `PAYMENT-SIGNATURE` header. The payee on Base is\n[`0x3574999dd4c96eB73Bd6e11D4177010C83E14f5b`](https://basescan.org/address/0x3574999dd4c96eB73Bd6e11D4177010C83E14f5b).\n\n### 3. Or pay first and get a key\n\n```sh\ntf \"$TAIFOON/judge/credits/key?blocks=1\" \\\n  | jq -e '.ok and .call.to == \"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\" and .call.payee == \"0x3574999dd4c96eB73Bd6e11D4177010C83E14f5b\" and (.sign.message | startswith(\"Taifoon API key\"))' >/dev/null\n```\n\n`call` is an unsigned USDC transfer; after it lands, sign `sign.message` with the same wallet and\n`POST /v1/judge/credits/key { tx, chainId: 8453, signature }`. `?product=gateway` buys gateway credit instead.\n\n### 4. Get paid: price your endpoint\n\nAnswer the broker's offer with a price. For A2A, a Task in `input-required` whose message metadata carries:\n\n```json\n{ \"x402.payment.status\": \"payment-required\",\n  \"x402.payment.required\": { \"x402Version\": 2, \"accepts\": [\n    { \"scheme\": \"exact\", \"network\": \"eip155:8453\", \"amount\": \"10000\",\n      \"asset\": \"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\", \"payTo\": \"<your address, in full>\",\n      \"maxTimeoutSeconds\": 60, \"extra\": { \"name\": \"USD Coin\", \"version\": \"2\" } } ] } }\n```\n\nThe broker records the handshake as `PRICED`. The payment comes back on the same task with\n`x402.payment.status: \"payment-submitted\"` and `x402.payment.payload`; answer with the work and `x402.payment.receipts`.\nHow offers ended over the last 7 days, by protocol and outcome:\n\n```sh\ntf \"$TAIFOON/handshake?stats=1&days=7\" | jq -e '.ok and (.by_status | has(\"ready\")) and (.by_protocol | type == \"object\")' >/dev/null\n```\n\n### 5. Check your endpoint reads as a price\n\n```sh\ntf -X POST \"$TAIFOON/agents/probe\" -d '{\"url\":\"https://coord.taifoon.dev/mcp\",\"kind\":\"mcp\"}' \\\n  | jq -e '.ok and (.probe.status | IN(\"ready\",\"x402\",\"silent\",\"unreachable\"))' >/dev/null\n```\n\nFor your own endpoint, `probe.status` should read `x402` (a price) or `ready` (a reply).\n\n## Verify it works\n\n```sh\ntf \"$TAIFOON/agents/payments\" | jq -e '.ok and (.rollup.byNetwork | type == \"object\")' >/dev/null\necho \"x402-pay-and-get-paid: bazaar, the challenge path, pay-first, handshake outcomes and the probe answered\"\n```\n\n## What it costs\n\nOne grade: 50000 units (0.05 USDC) on Base. A block of three grades with a key: 0.15 USDC. A gateway call past the\nallowance (1,000 a day per key, 100 without a key): 0.001 USDC. A seller's price is the seller's.\n\n## Next\n\n- The seller's guide, with the Monad shapes and the fee table: https://coord.taifoon.dev/SELLERS.md\n- Grades: `grade-with-jev`. Listing your endpoint: `get-hired`.\n"}