# x402 Work > x402 Work is an open HTTP 402 payment scheme where the payment is proof of work. A server answers a request with 402 and a small mining puzzle; the client solves it and retries the same request with the answer, and the server responds. No wallet, account, API key or funds, and nothing that ties a payment to a person. It is the x402 v2 protocol (PAYMENT-REQUIRED, PAYMENT-SIGNATURE, PAYMENT-RESPONSE headers) with scheme "work" instead of the "exact" stablecoin scheme. A profile names the proof-of-work algorithm and network, so any proof-of-work chain can price requests. Built by Dominant Strategies (the team behind Quai) and proposed to x402: https://github.com/dominant-strategies/x402/pull/3 (work scheme) and https://github.com/dominant-strategies/x402/pull/2 (exact payments on Quai). This site hosts the explainer, the facilitator for sellers, the marketplace, a demo and public statistics. ## What this deployment hosts - Work facilitator (https://x402.qu.ai/v1/facilitator): network quai:9 with profiles quai/sha256d-v1, quai/scrypt-v1, quai/kawpow-v1; network monero:418015bb9ae982a1975da7d79277c270 with profiles monero/randomx-v1. Live list: GET https://x402.qu.ai/v1/facilitator/supported. - Quai exact facilitator (https://x402.qu.ai/v1/quai): networks quai:9, quai:15000, direct native QUAI and Qi in Cyprus-1. Live list: GET https://x402.qu.ai/v1/quai/supported. - Discovery: https://x402.qu.ai/.well-known/x402 lists the paid resources on this origin, the facilitators and these links. ## The scheme in one paragraph A 402 offer in PAYMENT-REQUIRED (base64 JSON) lists accepts[] entries with scheme "work", network (such as "quai:9"), asset "hash", amount (the price in expected guesses), payTo (the seller's QUAI address), maxTimeoutSeconds (15 on this site: the job's expiresAt is at most that many seconds after the offer) and extra {name:"x402-work", version:"1", profile, job}. Profiles: quai/sha256d-v1 (solvable in any language with SHA-256: x402-work-client in Node, or the standard-library Python payer at https://x402.qu.ai/docs/pay/raw), quai/scrypt-v1 (x402-work-client) and quai/kawpow-v1 (needs an external GPU miner). On a CPU, SHA-256d work is cheap to produce and worth little next to ASICs, so sellers price it accordingly. A valid answer's score is at or below floor(2^256 / amount) - 1. Retry with PAYMENT-SIGNATURE = base64 JSON {x402Version:2, resource, accepted, payload:{solution}}, copying resource and accepted exactly. The 200 carries PAYMENT-RESPONSE = base64 JSON {success, transaction, network, amount, extra}. A proof pays once. ## Byte order (quai/sha256d-v1 and quai/scrypt-v1) The solution is {extraNonce2, time, nonce}, lowercase 0x hex. nonce and time are the big-endian hex of the uint32 ("0x00000375" means 885); the 80-byte header stores version, time, bits and nonce little-endian, previousBlockHash with each 4-byte word reversed, the merkle root as computed, and extraNonce2 copied into the coinbase byte for byte. The score is the digest read as a little-endian number. A worked test vector, checked against the server's verifier, is in https://x402.qu.ai/docs/pay.md (section "Worked example"). ## Pay for a request (agents, scripts, backends) - Node library: `npm install https://x402.qu.ai/x402-work-client-0.4.1.tgz`, then `import { payWithWork } from "x402-work-client"` and `await payWithWork(url, body, { maxPrice })`. body undefined sends GET; an object is POSTed as JSON. Offers above maxPrice (in guesses) are refused before any work starts. Solves quai/sha256d-v1 and quai/scrypt-v1 offers (SHA-256d preferred), plus monero/randomx-v1 when X402_WORK_RANDOMX_SOLVER is set, randomx: { solver: path } is passed, or a lazy randomx callback resolves it. The current CLI finds a solver on PATH or downloads and SHA-256-verifies a prebuilt for Linux or macOS (Intel and Apple Silicon). In a library, explicitly opt in: import { ensureRandomxSolver } from x402-work-client/solver; pass randomx: async () => ({ solver: await ensureRandomxSolver() }). A cap error lists every offered algorithm with its own limit instead of quoting only SHA-256d. RandomX defaults to at most 150,000 expected guesses and fast mode when at least 3 GiB is available to the process, including container limits. Set randomx.fast or X402_WORK_RANDOMX_FAST=0/1 to choose light/fast explicitly; the CLI accepts --randomx-mode auto|fast|light. The job deadline remains a hard stop. Returns { response, payment: { price, profile, guesses, milliseconds, receipt } }. - Shell, in the same project: `npx x402-work pay [--data ''] [--max-price N] [-o file]`. Without a project: `npx --yes --package https://x402.qu.ai/x402-work-client-0.4.1.tgz x402-work pay `. - Without the client: the exchange, challenge fields, byte order, the worked example and troubleshooting are in https://x402.qu.ai/docs/pay.md. - Try it: GET https://x402.qu.ai/x402/v1/demo/image is a real 402 that unlocks a hidden image (a GIF). - 503 from any endpoint means nothing was charged: wait the Retry-After seconds (error.retryAfterSeconds in the JSON body) and retry. A fresh 402 with error invalid_work_target means the score missed the target, often a byte-order mistake. ## Charge for a request (sellers) The facilitator does the blockchain side: it issues each buyer a job built for the seller's own Quai address (Quai is solo-mineable, so the coinbase pays the seller), then verifies and spends each answer once and submits answers that meet the network threshold. x402 Work never holds funds. No account; requests are rate-limited. - With the client: `import { workSeller, WorkSellerError } from "x402-work-client"`; `const seller = workSeller({ payTo, amount })`; per request `await seller.charge({ url, paymentSignature })` returns { paid:false, status:402, headers, body } to send, or { paid:true, receipt, headers } to attach to your 200. It throws WorkSellerError (status, retryAfter, code) when the facilitator is unavailable: answer 503 with Retry-After. - GET https://x402.qu.ai/v1/facilitator/supported: {kinds:[{x402Version:2, scheme:"work", network, extra:{name:"x402-work", version:"1", profiles:[...]}}]}; kinds is empty when no work source is configured. - POST https://x402.qu.ai/v1/facilitator/requirements {payTo, amount, profile?, resource:{url, description?, mimeType?}} → 201 {paymentRequired, paymentRequiredHeader, challengeId, expiresAt}. amount is required (decimal string of expected guesses). Errors name the field (payTo, amount, resource.url, profile). Send the result as your 402. - POST https://x402.qu.ai/v1/facilitator/verify {x402Version:2, paymentPayload, paymentRequirements} → {isValid, invalidReason?, invalidMessage?}. Spends and submits nothing. Legacy {paymentSignature, payTo, amount, resource} is also accepted. - POST https://x402.qu.ai/v1/facilitator/settle (same body) → {success, transaction, network, amount, extra:{sourceAccepted}, paymentResponseHeader} or {success:false, transaction:"", network, errorReason, errorMessage?}, both with HTTP 200. On false, send a fresh 402. - Matching rules for standard requests: paymentRequirements and paymentPayload.accepted must match the offer the facilitator issued on scheme, network, asset, amount, payTo, extra.name, extra.version, extra.profile and extra.job (id, expiresAt, refreshAfter, work). payTo compares case-insensitively, so a checksummed address is fine. maxTimeoutSeconds and unknown fields are ignored (use 15). A mismatch returns invalid_work_payload with invalidMessage naming the fields. Standard HTTPFacilitatorClient and WorkServerScheme work with a remote issuer that gets jobs from /v1/facilitator/requirements. - Get listed in a browser: https://x402.qu.ai/marketplace/publish. Save the management key or download its recovery file; the key is never placed in a URL. Verify the API host, then submit for operator review. - Get listed, no account: POST https://x402.qu.ai/v1/marketplace/listings {title, summary, description, category, websiteUrl, endpoint, method, profile, probeBody?, contact?} → 201 with id, manageToken (shown once) and a DNS TXT record to set on the API host (the website may use another host). Then POST https://x402.qu.ai/v1/marketplace/listings/{id}/submit with Authorization: Bearer : it checks the TXT record and that an unpaid request to endpoint gets a 402 work offer for profile. Passing listings go to operator review (the one human step); poll GET https://x402.qu.ai/v1/marketplace/listings/{id} for published or rejected (listing.reviewNote). DELETE withdraws. Published service statistics include past and future facilitator settlements matching the endpoint, work profile and payTo; this does not change payouts and does not prove delivery. - Guide: https://x402.qu.ai/docs/sell.md. ## Schemes - work (x402 Work): payment is one proof-of-work solution; requirements carry asset "hash", amount in expected trials, payTo and extra {name:"x402-work", version:"1", profile, job}; target floor(2^256/amount)-1; settlement atomically consumes a fingerprint, which is the receipt's transaction, and omits payer. Quai profiles quai/sha256d-v1, quai/scrypt-v1, quai/kawpow-v1 (hosted here: quai:9). Errors: invalid_work_payload, _profile, _stale, _target, _state, _settled, _conflict. Spec: https://github.com/dominant-strategies/x402/pull/3. Guide: https://x402.qu.ai/docs/scheme-work.md. - exact on Quai: native QUAI (asset slip44:994, amount in wei, signed type 0 transaction) and Qi (slip44:969, amount one qit denomination, signed type 2 transaction, fresh payTo per payment); same-zone only; settled after inclusion. The spec also defines sponsored QUAI and ERC-20 tokens on eip155:9; neither is enabled here. Spec: https://github.com/dominant-strategies/x402/pull/2. Guide: https://x402.qu.ai/docs/scheme-exact-quai.md. ## Facilitators and libraries - Hosted facilitators and their status: https://x402.qu.ai/docs/facilitators.md. POST https://x402.qu.ai/v1/quai/verify and /v1/quai/settle take {x402Version:2, paymentPayload, paymentRequirements}. Verify never broadcasts. Settle succeeds after inclusion (allow up to about two minutes), reserves transaction hashes durably and rejects replay. If submission times out, retry that same payload to reconcile; do not automatically pay again. Qi receipts omit payer. - Libraries, served by this site (manifest with sha256 and npm integrity: https://x402.qu.ai/x402-packages.json). @x402/core and other third-party dependencies come from npm. - x402-work-client 0.4.1: `npm install https://x402.qu.ai/x402-work-client-0.4.1.tgz` (sha256 2a276f40b2598cbc238549071a387c5df76a00729a268ddfa8eac7c8a0b1523a). Pay any work 402 (payWithWork, SHA-256d, Scrypt and RandomX with the native solver), charge through the hosted facilitator (workSeller), and the x402-work command. - @x402/work 2.20.0: `npm install https://x402.qu.ai/x402-work-2.20.0.tgz` (sha256 554edb03bfc432a4b06c68b5df6a714b512f8eeb5242de9b2a2bf874f99c7b20). The work scheme for the x402 SDK: WorkClientScheme, WorkServerScheme and WorkFacilitatorScheme. - @x402/quai 2.20.0: `npm install https://x402.qu.ai/x402-quai-2.20.0.tgz` (sha256 a9c38518f91554ec943a7b4d29bc4d1f26dcdf5036a90b54ec1bc67131ae5353). The exact scheme for direct native QUAI and Qi: ExactQuaiScheme for client, server and facilitator. Payer-funded fees only; no sponsored QUAI or EVM adapters in this build. - x402-work-http 0.1.0: `npm install https://x402.qu.ai/x402-work-http-0.1.0.tgz` (sha256 e7b6c3d97e842bc059c4c271bcc4da27ed6ae5e61c36146301864f99a7cb2f16). A framework-neutral HTTP gate (createWorkGate) for running your own work verification and settlement. - x402-work-provider 0.1.2: `npm install https://x402.qu.ai/x402-work-provider-0.1.2.tgz` (sha256 94dd181036a61c5b1256835e024c41ab9b95686a3a95a3521e0d543ae9f07335). Quai StratumX profiles, Monero RandomX pool profiles (RandomxProfile) and the Go native verifier source (GoQuaiVerifier), for self-hosting. - x402-work-randomx for darwin-amd64: https://x402.qu.ai/x402-work-randomx-darwin-amd64 (sha256 d2e2c2bc592b256446324bff62466cbfd0e08489733a9bcbb020845161f44766). Native RandomX solver for macOS (Apple Silicon or Intel). - x402-work-randomx for darwin-arm64: https://x402.qu.ai/x402-work-randomx-darwin-arm64 (sha256 e42cd32135cad9d8ef9202810d082f8ecd26b91909db0cbb9435f4b39ca7c4f7). Native RandomX solver for macOS (Apple Silicon or Intel). - x402-work-randomx for linux-amd64: https://x402.qu.ai/x402-work-randomx-linux-amd64 (sha256 bc7cf08c1436819dd7ab61816796d606ca56db77f89a68ab614e22f90ebd0e89). Native RandomX solver (static Linux build). - x402-work-randomx for linux-arm64: https://x402.qu.ai/x402-work-randomx-linux-arm64 (sha256 8046df9ba750e365b02083f2cc181421c91d78c7ec27b9975ab0daec64861e42). Native RandomX solver (static Linux build). - Guide: https://x402.qu.ai/docs/libraries.md. ## Services - Hashference (https://hashference.com): open models paid per request with work, no key. POST https://hashference.com/x402/v1/chat/completions, /x402/v1/responses or /x402/v1/messages with the normal request body; models from https://hashference.com/v1/catalog; status and prices at https://hashference.com/v1/x402. With an API key, the same models run from a balance instead (https://hashference.com/llms.txt). - Marketplace: GET https://x402.qu.ai/v1/marketplace/services lists each service's absolute endpoint, method, price, profile and availability; GET https://x402.qu.ai/v1/marketplace/services/{slug} reads one. Hosted tools (json-workbench, text-toolkit, model-catalog) are bought with POST https://x402.qu.ai/x402/v1/marketplace/{slug} {consent:true, input}; save extensions["quai-marketplace"].resultKey from the 402 privately to recover a settled result for ten minutes via POST https://x402.qu.ai/v1/marketplace/jobs/{jobId}/result. A replayed proof gets 409 there (recover instead); standard resources such as the demo answer a replay with a fresh 402 (invalid_work_state). Guide: https://x402.qu.ai/docs/marketplace.md. - Statistics: GET https://x402.qu.ai/v1/stats?days=1|7|30|90: work payments per day here and on Hashference, and services by completed purchases. Public aggregates only. ## Rules - Start work only with consent, inside a time and guess limit. - Check the offer before solving: resource URL, network, profile, payTo, amount and expiry. - Keep the request identical on both calls; a different body is a different price and gets a fresh 402. - Jobs live briefly (15 seconds here). Stop at refreshAfter or expiresAt and ask for a new one. - A receipt proves an access payment. It is not a balance, a credit or a promise of a mining reward. - Sellers: always settle against your own payTo, amount and resource, so a proof bought for something else can't pay for yours. ## Machine interfaces - [Full documentation](https://x402.qu.ai/llms-full.txt): every guide below in one Markdown file. - [OpenAPI](https://x402.qu.ai/openapi.json): every operation with typed responses and the PAYMENT-* headers. - [Discovery](https://x402.qu.ai/.well-known/x402): paid resources, facilitators and links. - [Capabilities](https://x402.qu.ai/v1/capabilities): live work profiles, facilitator status and discovery links. - [Facilitator](https://x402.qu.ai/v1/facilitator/supported) - [Marketplace](https://x402.qu.ai/v1/marketplace/services) - [Statistics](https://x402.qu.ai/v1/stats) - [Packages](https://x402.qu.ai/x402-packages.json) ## Guides Each guide is also Markdown at the link below; all of them together are at https://x402.qu.ai/llms-full.txt. - [What is x402 Work?](https://x402.qu.ai/docs/introduction.md): x402 Work is a way to pay for an HTTP request with a few seconds of computation instead of money from a wallet. - [How it works](https://x402.qu.ai/docs/how-it-works.md): Two ordinary HTTP requests with a small puzzle in between. - [Pay with work](https://x402.qu.ai/docs/pay.md): Pay for any request that offers x402 work, from Node, an agent, a backend or a script. No account or wallet. - [Accept work payments](https://x402.qu.ai/docs/sell.md): Put a work price on any HTTP route. The work is built for your Quai address, and you run no node, verifier or database. - [Facilitators](https://x402.qu.ai/docs/facilitators.md): A facilitator verifies and settles x402 payments for a seller. Use a hosted one, or run your own with the libraries. - [Libraries](https://x402.qu.ai/docs/libraries.md): Pay and charge with x402 Work, or settle QUAI and Qi, from TypeScript. - [The work scheme](https://x402.qu.ai/docs/scheme-work.md): Pay for an x402 resource with one proof-of-work solution. A profile defines the job, the proof and the score; the scheme defines everything else. - [Exact payments on Quai](https://x402.qu.ai/docs/scheme-exact-quai.md): Standard x402 exact payments in native QUAI or Qi: a specific amount from the client to the seller, settled on Quai. - [Inference with Hashference](https://x402.qu.ai/docs/hashference.md): Hashference, the first service on x402 Work, serves open models paid per request with work. - [Marketplace](https://x402.qu.ai/docs/marketplace.md): Find services that take work, buy a hosted tool, and recover a result you paid for.