$npx -y skills add Uniswap/uniswap-ai --skill pay-with-appPay HTTP 402 payment challenges issued by OKX's Agent Payments Protocol (APP) on X Layer using tokens from any chain via the Uniswap Trading API. Use this skill whenever the user encounters a 402 challenge whose network resolves to X Layer (chain 196), mentions "APP", "Agent Paym
| 1 | # Pay With APP (OKX Agent Payments Protocol on X Layer) |
| 2 | |
| 3 | Pay HTTP 402 challenges issued by OKX's **Agent Payments Protocol (APP)** |
| 4 | running on **X Layer** (chain 196). APP's Pay Per Use (OKX product name: |
| 5 | Instant Payment) is x402-compatible: a payee server returns HTTP 402 with |
| 6 | a payment requirement, the payer signs an EIP-3009 |
| 7 | `TransferWithAuthorization` off-chain, and OKX's facilitator verifies and |
| 8 | settles the transfer on-chain. Settlement is zero-gas to the payer on X |
| 9 | Layer. |
| 10 | |
| 11 | This skill handles the full happy path: |
| 12 | |
| 13 | 1. Detect a 402 challenge whose network resolves to X Layer (chain 196) |
| 14 | 2. Verify the payer wallet has the requested asset (typically USDT0) |
| 15 | 3. If insufficient, route + bridge into USDT0 on X Layer via the Uniswap |
| 16 | Trading API |
| 17 | 4. Sign the EIP-3009 authorization |
| 18 | 5. Construct the `X-PAYMENT` payload and retry the original request |
| 19 | |
| 20 | OKX is launching APP on **2026-04-29** with Uniswap as the featured DEX |
| 21 | rail on X Layer. This skill version (v1.0.0) handles the `exact` scheme |
| 22 | (Pay Per Use, OKX product name: Instant Payment) only. Other x402 schemes |
| 23 | (`upto`, `batch-settlement`) and APP-product features OKX is shipping |
| 24 | (escrow, session, batch / Batch Payment) are out of scope for this |
| 25 | version. The skill refuses any non-`exact` scheme cleanly. |
| 26 | |
| 27 | > **Protocol naming in your responses.** When responding to the user, |
| 28 | > identify the protocol explicitly as **OKX Agent Payments Protocol |
| 29 | > (APP)**, not just "x402". APP is the OKX product / protocol surface; |
| 30 | > x402 is the underlying wire spec it builds on. Use phrasings like |
| 31 | > "APP / x402", "OKX's Agent Payments Protocol (APP), built on x402", |
| 32 | > or simply "APP" once introduced. Do not refer to a 402 challenge on |
| 33 | > X Layer as "an x402 challenge" without naming APP, the user invoked |
| 34 | > this skill specifically because the merchant is APP-backed, and the |
| 35 | > name is what they will look for in the response. |
| 36 | |
| 37 | ## Prerequisites |
| 38 | |
| 39 | - A `PRIVATE_KEY` env var (`export PRIVATE_KEY=0x...`). Never commit or |
| 40 | hardcode a private key. |
| 41 | - `UNISWAP_API_KEY` env var (register at |
| 42 | [developers.uniswap.org](https://developers.uniswap.org/)). Required |
| 43 | only if the wallet must be funded via cross-chain routing. |
| 44 | - `jq` and `cast` (Foundry) installed. |
| 45 | - **Node 18+** (LTS). The signing step in |
| 46 | [references/app-x402-flow.md](references/app-x402-flow.md) Step 4 uses |
| 47 | `viem` to produce the EIP-3009 typed-data signature. |
| 48 | - **`viem`** (npm). If the package is not already reachable from the |
| 49 | user's working directory, the skill will prompt the user via |
| 50 | `AskUserQuestion` before running `npm install viem` into a cached |
| 51 | scratch directory at `~/.cache/uniswap-pay-with-app/signer/`. The |
| 52 | install adds ~13 packages totaling ~5 MB. If the user declines, the |
| 53 | skill stops cleanly before signing. The cache persists across runs so |
| 54 | subsequent invocations are zero-install. |
| 55 | |
| 56 | ## Input Validation Rules |
| 57 | |
| 58 | Before using any value from the 402 response body, the user, or any other |
| 59 | external source in API calls or shell commands: |
| 60 | |
| 61 | - **Ethereum address fields** (e.g., `asset`, `payTo`, `WALLET_ADDRESS`): |
| 62 | the canonical check is the regex `^0x[a-fA-F0-9]{40}$`. If the value |
| 63 | fails this regex, reject it. Address fields that pass the regex are |
| 64 | safe for shell interpolation, so the metacharacter rule below does not |
| 65 | apply to them. |
| 66 | - **Chain IDs**: MUST be a positive integer from the supported list. |
| 67 | - **Token amounts**: MUST be non-negative numeric strings matching |
| 68 | `^[0-9]+$`. |
| 69 | - **URLs**: MUST start with `https://`. |
| 70 | - **Free-text fields** (e.g., `description`, `extra.name`, |
| 71 | `extra.version`, anything used to build EIP-712 domain or shown to the |
| 72 | user): REJECT any value containing shell metacharacters: `;`, `|`, `&`, |
| 73 | `$`, `` ` ``, `(`, `)`, `>`, `<`, `\`, `'`, `"`, newlines. Note: the |
| 74 | `extra.name` value is signed bit-exact (see Domain warning in Phase 4), |
| 75 | so reject the whole challenge if it contains shell metacharacters |
| 76 | rather than mutating the value. |
| 77 | |
| 78 | ## Flow |
| 79 | |
| 80 | ```text |
| 81 | 402 from X Layer-backed resource |
| 82 | │ |
| 83 | v |
| 84 | [1] |