Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

docs(okx): pin down seller-side OKX Agent Payments Protocol spec (WO-01)

fudjia4be939f9eedf
diff --git a/prompts/okx-ai/PROGRESS.md b/prompts/okx-ai/PROGRESS.md
index ed89e8374..450c7b5f4 100644
--- a/prompts/okx-ai/PROGRESS.md
+++ b/prompts/okx-ai/PROGRESS.md
@@ -78,8 +78,10 @@ is the only blocker to a fully-successful paid leg.
### Answers that unblock WO 02 (details + citations in the spec)
-- **Header divergence (the核心 delta):** buyer sends **`PAYMENT-SIGNATURE`** (not vanilla
- x402's `X-PAYMENT`); success receipt is **`PAYMENT-RESPONSE`** (not `X-PAYMENT-RESPONSE`).
+- **Header delta:** the OKX rail uses **`PAYMENT-SIGNATURE`** (buyer→seller) + **`PAYMENT-RESPONSE`**
+ (seller→buyer) — these are the **x402 v2 standard** names (confirmed vs coinbase/x402 spec), NOT
+ an OKX invention. Our code emits the older **x402 v1** names (`X-PAYMENT`/`x-payment-response`)
+ while labeling itself "v2" — that's the delta to close for the X-Layer rail.
- **Challenge:** `PAYMENT-REQUIRED` header (base64) + body; per-accept required fields =
`scheme, network:"eip155:196", asset(USD₮0 0x779ded…), payTo, amount, maxTimeoutSeconds,
extra.name:"USD₮0", extra.version:"1"`. `extra` uses `transferMethod` (NOT
diff --git a/specs/okx-agent-payments.md b/specs/okx-agent-payments.md
index c0f1cbd77..a99d87e37 100644
--- a/specs/okx-agent-payments.md
+++ b/specs/okx-agent-payments.md
@@ -18,6 +18,8 @@ This is a load-bearing contract in the sense of `specs/README.md`: 02's implemen
- **WIRE-OKB** — live 402 from **OKB Monitoring** (agent #3837, approvalStatus 4), `https://okb.swaper.money/x402/digest` (Appendix C).
- **PAY-LEG1/2** — real `onchainos payment pay` signing + paid replay from our own wallet (Appendix D).
- **SKILL** — repo client-side skill `.claude/skills/okx-agent-payments-protocol/` (buyer constraints).
+- **SKILLS-REPO** — `github.com/okx/onchainos-skills` (the `onchainos` CLI + listing validator `cli/…/identity/validate.rs`).
+- **X402-SPEC** — `github.com/coinbase/x402` (`specs/x402-specification-v2.md`, `specs/transports-v2/http.md`) — establishes that `PAYMENT-SIGNATURE`/`PAYMENT-RESPONSE` are the x402 v2 standard, not an OKX invention.
---
@@ -157,9 +159,9 @@ On success attach `PAYMENT-RESPONSE` (base64 of the `SettleResponse`). Shape (SD
| 2 | Which scheme(s) mandatory for listing | **`exact` (EIP-3009) is the one required scheme** — present in all 3 approved sellers. `aggr_deferred` is offered by 2/3 (optional, recommended as a second accept). **`upto` is offered by none** and is NOT needed for approval. `upto` (if ever added) requires `extra.facilitatorAddress`, which the seller must fetch from the facilitator's `/supported.signers` — it cannot be hardcoded. | WIRE-* diff; SDK `upto/facilitator/scheme.ts:29-39`, `upto/client/permit2.ts:32-38`; SKILL `accepts-schemes.md` |
| 3 | Fee token `0x779Ded…713736` on X Layer | **Symbol `USDT`, name `USD₮0`, decimals `6`, EIP-3009 capable** (supports `transferWithAuthorization`). Community-recognized. Not permit2-only — the whole rail uses EIP-3009. | `onchainos token info` (Appx E); SDK `defaultAssets.ts` `DEFAULT_STABLECOINS["eip155:196"]` comment "(EIP-3009)"; live EIP-3009 sign accepted structurally by facilitator (PAY-LEG1/2) |
| 4 | OKX facilitator verify/settle URLs, shapes, auth | Base `https://web3.okx.com`. **`POST /api/v6/pay/x402/verify`**, **`POST /api/v6/pay/x402/settle`**, `GET /api/v6/pay/x402/supported`, `GET /api/v6/pay/x402/settle/status?txHash=`. Body `{x402Version:2, paymentPayload, paymentRequirements[, syncSettle]}`. Responses wrapped `{code,msg,data}`. **Auth = OKX REST HMAC-SHA256**: headers `OK-ACCESS-KEY`, `OK-ACCESS-SIGN`(=base64(HMAC-SHA256(secret, timestamp+method+path+body))), `OK-ACCESS-TIMESTAMP`(ISO-8601), `OK-ACCESS-PASSPHRASE`. **⇒ We need an OKX API key/secret/passphrase.** `upto`'s `extra.facilitatorAddress` = `supported.signers[family][0]` via `getExtra()`. | SDK `facilitator/OKXFacilitatorClient.ts` (all endpoints + `createHeaders` L60-76); `upto/facilitator/scheme.ts:39` |
-| 5 | The official OKX Payment SDK | **`github.com/okx/payments` = "OKX Payments SDK", Apache-2.0.** Published on npm: `@okxweb3/app-x402-core`, `@okxweb3/app-x402-evm`, `@okxweb3/app-x402-next`, `@okxweb3/app-x402-express` — all **v0.2.0**. Pure TypeScript (`fetch` + `node:crypto`, no native bindings) ⇒ **runs in Vercel functions**. Seller-side it: builds the 402 challenge (`x402ResourceServer`+`ExactEvmScheme`), reads `PAYMENT-SIGNATURE`, calls facilitator verify/settle, emits `PAYMENT-RESPONSE`. `@okxweb3/app-x402-next` ships `withX402` (API-route wrapper) + `paymentProxy` (middleware). | SDK-REPO README + `package.json` names; `npm view @okxweb3/app-x402-next version` → `0.2.0`; `app-x402-next/README.md` |
+| 5 | The official OKX Payment SDK | **`github.com/okx/payments` = "OKX Payments SDK", Apache-2.0** (monorepo `@okxweb3/payments-sdk-monorepo`; Go/Python/Rust/TS/Java). **Use the `@okxweb3/app-x402-*` family @ v0.2.0** (`-core`, `-evm`, `-express`/`-next`/`-hono`/`-fastify`, `-mpp`) — that's what the runnable demo imports (published 2026-07-03). **⚠️ Avoid the stale `@okxweb3/x402-*` @ v0.1.0** (`x402-core`/`x402-evm`/`mpp`) that the repo's `SELLER.md` still names — last touched 2026-06-08. Pure TypeScript (deps `viem`/`zod`/`axios`/`mppx` — pure JS, `@noble` crypto, `node:crypto` HMAC, no native bindings) ⇒ **runs in Vercel functions**. Seller-side it builds the 402 challenge, reads `PAYMENT-SIGNATURE`, calls facilitator verify/settle, emits `PAYMENT-RESPONSE`, plus lifecycle hooks + metered `setSettlementOverrides`. Weekly downloads low (new pkg): app-x402-core ≈267, -evm ≈204, -express ≈188. | SDK-REPO README + `package.json`; `npm view @okxweb3/app-x402-*`; `api.npmjs.org/downloads/point/last-week`; `app-x402-next/README.md` |
| 6 | HTTP-level 402 vs MCP-level PaymentRequired | OKX expects **HTTP-level 402** on the endpoint URL: real `HTTP/2 402` status + `PAYMENT-REQUIRED` header, paid replay via `PAYMENT-SIGNATURE` header. All 3 approved sellers do HTTP-level. **Our current MCP-level `_meta` PaymentRequired (structuredContent) is NOT what OKX reads** — the validator/buyer never inspects JSON-RPC `_meta`. 02 must add an HTTP-402 gate at the transport layer of `api/mcp-3d.js`. (oklink's endpoints are "MCP" by name but gate at HTTP: `POST` → 402, headers carry payment; see Appx A.) | WIRE-OKLINK (POST→402, GET→405); [api/mcp-3d.js](../api/mcp-3d.js) `_meta` path; SDK is HTTP-transport only |
-| 7 | How listing review validates the endpoint | The seller registers each service with an **`endpoint` URL + `fee` + fee-token `contractAddress` (`0x779ded…`) + `chainIndex 196`** (see `onchainos agent service-list` output, Appx F). Approval requires the endpoint to answer the gated method (`POST` for oklink) with a `402` whose `accepts` advertise **`eip155:196` + the USD₮0 fee token** at the registered price. The `onchainos agent x402-check --endpoint` / `x402-validate` CLI is the same validator surface: it flags `"Endpoint returned HTTP 200 (not 402); not a valid x402 service"` when the gate is absent (Appx E). Our rejection ("A2MCP service has not been integrated with the OKX Agent Payments Protocol") = our endpoint never returns a `eip155:196` 402. **UNRESOLVED:** the exact HTTP method + body the automated validator sends, and any endpoint-URL format constraint, are not documented in a primary source — 02 should register, run `onchainos agent x402-check --endpoint https://three.ws/api/mcp-3d`, and confirm it reports `valid:true` before resubmitting. | `onchainos agent x402-check` (Appx E); `service-list` schema (Appx F); rejection email (00-CONTEXT) |
+| 7 | How listing review validates the endpoint | Two layers. **(a) Registration-time `validate-listing` is PURE-LOCAL — no HTTP probe** (`onchainos-skills` `cli/…/identity/validate.rs`): it only checks A2MCP has an `endpoint`, the URL is `https://` + publicly reachable (rejects `http`, `localhost`, `127.0.0.1`, RFC-1918, `*.local/.internal`, mock/placeholder, >512 chars), fee is a plain number (USDT implicit), description has no URLs/addresses. It writes the endpoint URL on-chain (ERC-8004). Service-type → rail: **`A2MCP → x402`**. **(b) Approval / rejection** ("A2MCP service has not been integrated with the OKX Agent Payments Protocol") is a **human/off-repo review** — no codified automated probe that asserts the 402 shape exists in `okx/payments` or `onchainos-skills`. To pass it, the live endpoint must emit a v2 `402` whose `accepts` advertise **`eip155:196` + USD₮0** at the registered price. **Self-check tool (manual, not the gate):** `onchainos agent x402-check --endpoint <url>` flags `"Endpoint returned HTTP 200 (not 402); not a valid x402 service"` when the gate is absent (Appx E). **UNRESOLVED:** the exact method/body of any OKX-side automated probe, and whether one exists, are undocumented (dev-portal pages are JS-rendered / 404 to fetch). 02 should register, run `x402-check` against `https://three.ws/api/mcp-3d`, confirm `valid:true`, then resubmit for (human) review. | `onchainos-skills` `identity/validate.rs`, `task-cli-reference.md:396`; `onchainos agent x402-check` (Appx E); rejection email (00-CONTEXT) |
| 8 | Settlement finality — how seller confirms payment | Seller trusts the facilitator's responses, not its own chain read. `/verify` → `isValid:true` gates doing the work (proves the signed authorization is valid + payer funded — a broke payer gets `isValid:false` / `insufficient_balance`, proven by PAY-LEG2). `/settle` → `{success, status}`: `syncSettle:true` ⇒ `status:"success"` (on-chain confirmed before responding); default async ⇒ `status:"pending"` (safe to release; poll `/settle/status?txHash` for finality). The `PAYMENT-RESPONSE` header carries `{success,status,transaction,payer,amount}` to the buyer. | SDK `OKXFacilitatorClient.ts` settle L124-150 + `syncSettle` docstring; `types/facilitator.ts:26-38`; PAY-LEG2 |
---
@@ -176,9 +178,11 @@ Per CLAUDE.md "Open-source first" checklist:
| Maintenance / provenance | Official OKX org (`okx/payments`), the SDK the rejection email points to. Multi-language, actively structured. v0.2.0 (early but first-party). | ✅ |
| License | **Apache-2.0** (`@okxweb3/app-mpp` is MIT). Compatible with our commercial use. | ✅ |
| Vercel compatibility | Pure TS, deps are `fetch` + `node:crypto` + `viem`-class EVM libs; no native addons. `@okxweb3/app-x402-next` targets Next/serverless directly. | ✅ |
-| Weekly downloads | Low (v0.2.0, new package, published ~2026-07). Mitigated by first-party status + our own tests. **UNRESOLVED exact number** — `npm view` returns version but the registry download-count API wasn't queried; treat as "new, first-party, low adoption." | ⚠️ acceptable |
+| Weekly downloads | Low — app-x402-core ≈267/wk, -evm ≈204, -express ≈188 (v0.2.0, published 2026-07-03). Mitigated by first-party status + our own tests. | ⚠️ acceptable |
-**Adoption shape for 02:** our endpoint is a bare Vercel function (`api/mcp-3d.js`, Node `req/res`), not a Next.js app-router route, so `withX402` (needs `NextRequest`/`NextResponse`) is not a drop-in. Use the framework-agnostic core: `@okxweb3/app-x402-core` (`x402ResourceServer`, `OKXFacilitatorClient`, the `HTTPAdapter` interface, header codecs) + `@okxweb3/app-x402-evm` (`ExactEvmScheme`). Write a ~30-line `HTTPAdapter` over our Node `req`. This gives the OKX 402/verify/settle for `eip155:196` alongside our current multi-chain `paymentRequirements()` for the other rails. Reference seller wiring: SDK `demo/x402/src/index.ts` (Express) and `app-x402-next/README.md` (`withX402`).
+**⚠️ Package trap:** install the **`@okxweb3/app-x402-*` v0.2.0** family (what the demo imports), NOT the stale **`@okxweb3/x402-*` v0.1.0** family the repo's `SELLER.md` documents (last touched 2026-06-08).
+
+**Adoption shape for 02:** our endpoint is a bare Vercel function (`api/mcp-3d.js`, Node `req/res`), not a Next.js app-router route, so `withX402` (needs `NextRequest`/`NextResponse`) is not a drop-in. Use the framework-agnostic core: `@okxweb3/app-x402-core` (`x402ResourceServer`, `OKXFacilitatorClient`, the `HTTPAdapter` interface, header codecs) + `@okxweb3/app-x402-evm` (`ExactEvmScheme`). Write a ~30-line `HTTPAdapter` over our Node `req`. This gives the OKX 402/verify/settle for `eip155:196` alongside our current multi-chain `paymentRequirements()` for the other rails. Reference seller wiring: SDK `demo/x402/src/index.ts` (Express) and `app-x402-next/README.md` (`withX402`). **Serverless caveat:** `await resourceServer.initialize()` calls the facilitator `/supported` and must run once per cold start (lazily) before the first paid request — it is what populates `upto`'s `facilitatorAddress` and validates scheme support.
**Env we must add:** `OKX_API_KEY`, `OKX_SECRET_KEY`, `OKX_PASSPHRASE` (facilitator HMAC), plus the payTo already known. **Blocker for 02:** these OKX API credentials must be provisioned by the owner from the OKX Web3 developer console. Without them every `/verify` and `/settle` fails auth. → raised in PROGRESS.
@@ -196,8 +200,8 @@ Reference: [api/_lib/x402-spec.js](../api/_lib/x402-spec.js) `paymentRequirement
| G4 | Field name `extra.assetTransferMethod` (permit2 path). | OKX exact uses `extra.transferMethod:"eip3009"` (or omit → EIP-3009 default). | Emit `transferMethod` (optional) — do NOT emit `assetTransferMethod` on the X-Layer accept. |
| G5 | Schemes `exact` (EIP-3009/permit2) + `direct` (BSC). **No `aggr_deferred`.** | `exact` mandatory; `aggr_deferred` recommended 2nd accept. | Emit `exact` for X-Layer; optionally add `aggr_deferred` accept (SDK `ExactEvmScheme`/aggr scheme). |
| G6 | Facilitator routing = CDP / PayAI / self / BSC-direct (`facilitatorFor()`). **No OKX facilitator.** | verify/settle at `https://web3.okx.com/api/v6/pay/x402/{verify,settle}` with HMAC auth. | Add an `OKXFacilitatorClient` route for `eip155:196` (adopt SDK, §3). |
-| G7 | Payment header read = **`X-PAYMENT`** (`decodePaymentHeader`, `verifyPayment`). | Buyer sends **`PAYMENT-SIGNATURE`**. | On the X-Layer path read `PAYMENT-SIGNATURE` (case-insensitive). Keep `X-PAYMENT` for the other rails. |
-| G8 | Success receipt = **`X-PAYMENT-RESPONSE`** (`encodePaymentResponseHeader`, L1122). | **`PAYMENT-RESPONSE`** header. | Emit `PAYMENT-RESPONSE` on the X-Layer success reply. |
+| G7 | Payment header read = **`X-PAYMENT`** (x402 v1 name; `decodePaymentHeader`, `verifyPayment`) — despite the file labeling itself "v2". | Buyer sends **`PAYMENT-SIGNATURE`** (the x402 **v2** standard name). | On the X-Layer path read `PAYMENT-SIGNATURE` (case-insensitive; also accept `x-payment` for v1 back-compat). Keep `X-PAYMENT` for the other rails. |
+| G8 | Success receipt = **`x-payment-response`** (x402 v1 name; set in `api/mcp-3d.js:107` etc.). | **`PAYMENT-RESPONSE`** (x402 v2 name). | Emit `PAYMENT-RESPONSE` on the X-Layer success reply. |
| G9 | Gating is **MCP-level** via `_meta` structuredContent in [api/mcp-3d.js](../api/mcp-3d.js). | **HTTP-level 402** on the endpoint URL. | Add an HTTP-402 gate at the transport layer (before/around the JSON-RPC handler) for the registered A2MCP resource URLs. |
| G10 | Body carries `extensions.bazaar` + `builder-code` + `offer-receipt`. | OKX sellers emit none of these on the `eip155:196` accepts. | Keep the OKX accept body minimal (`x402Version/resource/accepts`); don't attach Bazaar extensions to it. |
| G11 | Facilitator auth = CDP JWT / bearer token. | OKX HMAC needs `OKX_API_KEY`/`OKX_SECRET_KEY`/`OKX_PASSPHRASE`. | Provision + wire the three env vars (owner blocker). |
@@ -226,18 +230,20 @@ Decoded body:
### B. WIRE-COINANK — CoinAnk OpenAPI #2013 (818 sales), `getUsBtcEtf`
-`GET` → `HTTP/2 402`. Emits BOTH `payment-required` (v2, 4 accepts) AND four `WWW-Authenticate: Payment` headers (MPP charge+session × two currencies USDG/USD₮0). `payment-required` decoded:
+`GET` → `HTTP/2 402`. Emits BOTH `payment-required` (v2, 4 accepts) AND four `WWW-Authenticate: Payment` headers (MPP charge+session). The seller offers each scheme in TWO currencies: the USD₮0 fee token AND a second X-Layer stablecoin. Only the **USD₮0** accepts matter for our contract; the second currency's mint/name are omitted here (not load-bearing, out of our USD₮0-only scope). USD₮0 accepts, decoded verbatim:
```json
{"x402Version":2,"accepts":[
- {"x402Version":2,"scheme":"exact","network":"eip155:196","amount":"1000","asset":"0x4ae46a509f6b1d9056937ba4500cb143933d2dc8","payTo":"0xb1257e75791baa36646113d8b1fdfc83b3e2d0b7","maxTimeoutSeconds":300,"extra":{"name":"Global Dollar","version":"1"}},
+ { "…second-stablecoin exact accept — identifiers omitted…" },
{"x402Version":2,"scheme":"exact","network":"eip155:196","amount":"1000","asset":"0x779ded0c9e1022225f8e0630b35a9b54be713736","payTo":"0xb1257e75791baa36646113d8b1fdfc83b3e2d0b7","maxTimeoutSeconds":300,"extra":{"name":"USD₮0","version":"1"}},
- {"x402Version":2,"scheme":"aggr_deferred","network":"eip155:196","amount":"1000","asset":"0x4ae46a509f6b1d9056937ba4500cb143933d2dc8","payTo":"0xb1257e75791baa36646113d8b1fdfc83b3e2d0b7","maxTimeoutSeconds":300,"extra":{"name":"Global Dollar","version":"1"}},
+ { "…second-stablecoin aggr_deferred accept — identifiers omitted…" },
{"x402Version":2,"scheme":"aggr_deferred","network":"eip155:196","amount":"1000","asset":"0x779ded0c9e1022225f8e0630b35a9b54be713736","payTo":"0xb1257e75791baa36646113d8b1fdfc83b3e2d0b7","maxTimeoutSeconds":300,"extra":{"name":"USD₮0","version":"1"}}],
"resource":{"url":"https://open-api.coinank.com/api/etf/getUsBtcEtf"}}
```
-`WWW-Authenticate` charge `request` decoded: `{"amount":"1000","currency":"0x779ded…713736","recipient":"0xb1257e…d0b7","methodDetails":{"chainId":196,"feePayer":true}}`.
+Structural takeaways (same across both currencies): each accept nests its own `x402Version:2`; `extra` is `{name, version}` only (no `symbol`/`transferMethod`/`decimals`); `resource` is `{url}` with no `mimeType`.
+
+`WWW-Authenticate` charge `request` (USD₮0) decoded: `{"amount":"1000","currency":"0x779ded…713736","recipient":"0xb1257e…d0b7","methodDetails":{"chainId":196,"feePayer":true}}`.
Session `request` decoded: adds `"escrowContract":"0x5E550002e64FaF79B41D89fE8439eEb1be66CE3b","minVoucherDelta":"10000"` and `"suggestedDeposit":"100000"`. (MPP rail — out of scope for 02.)
### C. WIRE-OKB — OKB Monitoring #3837, `/x402/digest`