[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M78B4TVW1NHTFSRV3APZRV18":3,"skill-same:01M78B4TVW1NHTFSRV3APZRV18":71},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":30,"commitSha":31,"skillDirectory":32,"forksCount":14,"repositoryHtmlUrl":33,"repositoryHomepageUrl":34,"ownerHtmlUrl":35,"ownerBlogUrl":36,"ownerDescription":37,"updatedAt":38,"install":39,"resources":52},"01M78B4TVW1NHTFSRV3APZRV18","pay-with-app",null,"Pay 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 Payments Protocol\", \"OKX agent payment\", \"OKX Onchain OS\", \"OKX agentic wallet\", \"x402 on X Layer\", \"USDT0\", \"x42\", \"Instant Payment\", \"Batch Payment\", \"pay for X Layer API\", or wants to pay an OKX-backed merchant. Even when the user does not explicitly say APP, prefer this skill for any 402 challenge whose network resolves to X Layer (chain 196). For 402 challenges on other chains (Ethereum, Base, Arbitrum, Tempo) use pay-with-any-token instead.","Solizardking\u002Fskillhub-main","Solizardking","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F108096810?v=4","01M786KDB10AYV042N0F9BD5B5","Clawd","01M786NYYXSZK1D05WM8JQPC48",0,"MIT","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fpublic\u002Fapi\u002Fskills\u002Fpay-with-app\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: pay-with-app\ndescription: >\n  Pay HTTP 402 payment challenges issued by OKX's Agent Payments Protocol\n  (APP) on X Layer using tokens from any chain via the Uniswap Trading API.\n  Use this skill whenever the user encounters a 402 challenge whose network\n  resolves to X Layer (chain 196), mentions \"APP\", \"Agent Payments\n  Protocol\", \"OKX agent payment\", \"OKX Onchain OS\", \"OKX agentic wallet\",\n  \"x402 on X Layer\", \"USDT0\", \"x42\", \"Instant Payment\", \"Batch Payment\",\n  \"pay for X Layer API\", or wants to pay an OKX-backed merchant. Even when\n  the user does not explicitly say APP, prefer this skill for any 402\n  challenge whose network resolves to X Layer (chain 196). For 402\n  challenges on other chains (Ethereum, Base, Arbitrum, Tempo) use\n  pay-with-any-token instead.\nallowed-tools: Read, Glob, Grep, Bash(curl:*), Bash(jq:*), Bash(cast:*), Bash(openssl:*), Bash(npx:*), Bash(node:*), WebFetch, AskUserQuestion\nmodel: opus\nlicense: MIT\nmetadata:\n  author: uniswap\n  version: '1.0.0'\n---\n\n# Pay With APP (OKX Agent Payments Protocol on X Layer)\n\nPay HTTP 402 challenges issued by OKX's **Agent Payments Protocol (APP)**\nrunning on **X Layer** (chain 196). APP's Pay Per Use (OKX product name:\nInstant Payment) is x402-compatible: a payee server returns HTTP 402 with\na payment requirement, the payer signs an EIP-3009\n`TransferWithAuthorization` off-chain, and OKX's facilitator verifies and\nsettles the transfer on-chain. Settlement is zero-gas to the payer on X\nLayer.\n\nThis skill handles the full happy path:\n\n1. Detect a 402 challenge whose network resolves to X Layer (chain 196)\n2. Verify the payer wallet has the requested asset (typically USDT0)\n3. If insufficient, route + bridge into USDT0 on X Layer via the Uniswap\n   Trading API\n4. Sign the EIP-3009 authorization\n5. Construct the `X-PAYMENT` payload and retry the original request\n\nOKX is launching APP on **2026-04-29** with Uniswap as the featured DEX\nrail on X Layer. This skill version (v1.0.0) handles the `exact` scheme\n(Pay Per Use, OKX product name: Instant Payment) only. Other x402 schemes\n(`upto`, `batch-settlement`) and APP-product features OKX is shipping\n(escrow, session, batch \u002F Batch Payment) are out of scope for this\nversion. The skill refuses any non-`exact` scheme cleanly.\n\n> **Protocol naming in your responses.** When responding to the user,\n> identify the protocol explicitly as **OKX Agent Payments Protocol\n> (APP)**, not just \"x402\". APP is the OKX product \u002F protocol surface;\n> x402 is the underlying wire spec it builds on. Use phrasings like\n> \"APP \u002F x402\", \"OKX's Agent Payments Protocol (APP), built on x402\",\n> or simply \"APP\" once introduced. Do not refer to a 402 challenge on\n> X Layer as \"an x402 challenge\" without naming APP, the user invoked\n> this skill specifically because the merchant is APP-backed, and the\n> name is what they will look for in the response.\n\n## Prerequisites\n\n- A `PRIVATE_KEY` env var (`export PRIVATE_KEY=0x...`). Never commit or\n  hardcode a private key.\n- `UNISWAP_API_KEY` env var (register at\n  [developers.uniswap.org](https:\u002F\u002Fdevelopers.uniswap.org\u002F)). Required\n  only if the wallet must be funded via cross-chain routing.\n- `jq` and `cast` (Foundry) installed.\n- **Node 18+** (LTS). The signing step in\n  [references\u002Fapp-x402-flow.md](references\u002Fapp-x402-flow.md) Step 4 uses\n  `viem` to produce the EIP-3009 typed-data signature.\n- **`viem`** (npm). If the package is not already reachable from the\n  user's working directory, the skill will prompt the user via\n  `AskUserQuestion` before running `npm install viem` into a cached\n  scratch directory at `~\u002F.cache\u002Funiswap-pay-with-app\u002Fsigner\u002F`. The\n  install adds ~13 packages totaling ~5 MB. If the user declines, the\n  skill stops cleanly before signing. The cache persists across runs so\n  subsequent invocations are zero-install.\n\n## Input Validation Rules\n\nBefore using any value from the 402 response body, the user, or any other\nexternal source in API calls or shell commands:\n\n- **Ethereum address fields** (e.g., `asset`, `payTo`, `WALLET_ADDRESS`):\n  the canonical check is the regex `^0x[a-fA-F0-9]{40}$`. If the value\n  fails this regex, reject it. Address fields that pass the regex are\n  safe for shell interpolation, so the metacharacter rule below does not\n  apply to them.\n- **Chain IDs**: MUST be a positive integer from the supported list.\n- **Token amounts**: MUST be non-negative numeric strings matching\n  `^[0-9]+$`.\n- **URLs**: MUST start with `https:\u002F\u002F`.\n- **Free-text fields** (e.g., `description`, `extra.name`,\n  `extra.version`, anything used to build EIP-712 domain or shown to the\n  user): REJECT any value containing shell metacharacters: `;`, `|`, `&`,\n  `$`, `` ` ``, `(`, `)`, `>`, `\u003C`, `\\`, `'`, `\"`, newlines. Note: the\n  `extra.name` value is signed bit-exact (see Domain warning in Phase 4),\n  so reject the whole challenge if it contains shell metacharacters\n  rather than mutating the value.\n\n## Flow\n\n```text\n402 from X Layer-backed resource\n  │\n  v\n[1] Parse the x402 challenge (Phase 0 below)\n  │\n  v\n[2] Confirm network resolves to X Layer (chain 196)\n  │   ├─ not chain 196 ──> escalate to pay-with-any-token, STOP\n  │   └─ chain 196\n  │\n  v\n[3] Check wallet balance of the requested asset on X Layer\n  │   ├─ sufficient ──> proceed to [5]\n  │   └─ insufficient\n  │        │\n  │        v\n  │   [4] Fund: route + bridge into the requested asset on X Layer\n  │        (Uniswap Trading API, see references\u002Ffunding-x-layer.md)\n  │\n  v\n[5] User Confirmation gate (see Phase 4 \u002F Step 5 below)\n[6] Sign EIP-3009 TransferWithAuthorization\n[7] Construct X-PAYMENT payload, retry the original request\n[8] Verify 200 + Payment-Receipt\n```\n\n## Phase 0, Parse the 402 Challenge\n\nThe x402 challenge is JSON in the response body. Extract:\n\n- `x402Version`, confirms x402 protocol version.\n- `accepts[].scheme`, only `\"exact\"` is supported in v1.0.0.\n- `accepts[].network`, accept `\"x-layer\"` \u002F `\"xlayer\"` \u002F `\"eip155:196\"` \u002F\n  `196`.\n- `accepts[].maxAmountRequired`, base units of the asset. Must match\n  `^[0-9]+$` AND be **strictly greater than zero**. A challenge with\n  `maxAmountRequired === \"0\"` is semantically broken (HTTP 402 by\n  definition demands a positive payment) and must be refused as\n  merchant misconfiguration. Do not rationalize zero as a \"ping\",\n  \"authentication\", or \"free-tier confirmation\"; OKX's facilitator\n  will not settle a zero-value `TransferWithAuthorization` and any\n  signature you produce is wasted. Surface this to the user and stop.\n- `accepts[].asset`, token contract on X Layer.\n- `accepts[].payTo`, recipient address.\n- `accepts[].resource`, the URL the facilitator binds the payment to.\n  Extract this when present. Use it as the retry target. If the field is\n  absent, fall back to the original request URL.\n- `accepts[].extra.name` and `accepts[].extra.version`, EIP-712 domain\n  values for the asset.\n- `accepts[].maxTimeoutSeconds`, used for `validBefore`.\n\n> **x402Version gate.** Confirm `x402Version === 1` immediately after\n> parsing. If it is anything else, refuse the challenge and surface a\n> version mismatch error to the user. v1.0.0 of this skill targets x402\n> v1 only (the v2 spec uses a different PaymentPayload structure).\n>\n> **Scheme gate.** Confirm `accepts[].scheme === \"exact\"`. The x402 spec\n> defines `exact`, `upto`, and `batch-settlement` schemes. v1.0.0 of this\n> skill supports `exact` only. If the chosen entry uses any other scheme,\n> refuse cleanly. (OKX's product surface uses its own vocabulary\n> including `charge` for their Instant Payment primitive; that is OKX\n> product marketing, not a wire scheme value. The wire-level scheme on\n> the `accepts[]` entry is what you check, and it must be `\"exact\"`.)\n\nIf multiple `accepts` entries are present, prefer the one whose `asset`\nthe wallet already holds on X Layer. If multiple options are equally\nviable, prefer USDT0 (deepest Uniswap funding-flow liquidity).\n\n**WOKB \u002F native OKB likely not eligible as APP settlement assets.** We\nhave not seen OKX publish WOKB or OKB as settlement assets; current\npublic dev docs list USDT0, USDG, and USDC as the supported stablecoin\nsettlement assets. If a 402 challenge ever surfaces a non-stablecoin\n`asset` (for example `WOKB`), refuse the challenge and ask the user to\nverify the merchant configuration.\n\n## Phase 1, Confirm Network is X Layer\n\n```bash\ncase \"$X402_NETWORK\" in\n  x-layer|xlayer|\"eip155:196\"|196)  X402_CHAIN_ID=196 ;;\n  *)\n    echo \"Network is not X Layer. Use pay-with-any-token instead.\"\n    exit 1\n    ;;\nesac\n```\n\n> If the network is not X Layer, **stop** and escalate to the\n> `pay-with-any-token` skill, which handles 402 challenges on Ethereum,\n> Base, Arbitrum, Tempo, and the other chains the Trading API supports.\n\n## Phase 2, Check Wallet Balance on X Layer\n\n> **REQUIRED:** You must have the user's source wallet address. Use\n> `AskUserQuestion` if not provided. Store as `WALLET_ADDRESS`.\n\n```bash\nASSET_BALANCE=$(cast call \"$X402_ASSET\" \\\n  \"balanceOf(address)(uint256)\" \"$WALLET_ADDRESS\" \\\n  --rpc-url https:\u002F\u002Frpc.xlayer.tech)\n\nif [ \"$ASSET_BALANCE\" -lt \"$X402_AMOUNT\" ]; then\n  echo \"Insufficient $X402_TOKEN_NAME on X Layer. Funding required.\"\n  # Proceed to Phase 3 (funding)\nfi\n```\n\n## Phase 3, Fund USDT0 on X Layer (only if needed)\n\nWhen the wallet lacks the requested asset, acquire it via the Uniswap\nTrading API: `EXACT_OUTPUT` quote with `tokenOutChainId=196` and\n`tokenOut` set to the X Layer asset address. The Trading API handles\nsame-chain swaps and cross-chain routing (powered by Across).\n\n> **Across coverage gap (verified 2026-04-27).** Across Protocol does\n> not currently list X Layer (chain 196) as a supported destination. As\n> a result, cross-chain `\u002Fquote` calls into chain 196 return\n> `ResourceNotFound: No quotes available` regardless of source chain.\n> Same-chain X Layer swaps (Phase A in `references\u002Ffunding-x-layer.md`)\n> are unaffected and work normally.\n>\n> **What this means for the agent in v1.0.0.** If the user holds funds\n> on a chain other than X Layer, the cross-chain leg must be done\n> through a bridge service that supports X Layer (the user runs that\n> step outside this skill, then re-invokes for the same-chain swap and\n> 402 settlement). Surface this honestly to the user, do not\n> recommend a specific bridge product (TODO: research and document a\n> co-marketing-aligned bridge recommendation in a follow-up).\n>\n> **When you defer the bridge to the user, your response must still\n> describe the FULL end-to-end flow**, not just the bridge step. After\n> identifying the Across gap and asking the user to bridge externally,\n> walk through what happens when they return: (1) re-check\n> `balanceOf` of the requested asset on X Layer, (2) if a same-chain\n> swap is needed (e.g. USDG to USDT0), describe the Trading API\n> EXACT_OUTPUT call and its Confirmation Gate, (3) construct the\n> EIP-3009 `TransferWithAuthorization` typed-data using `extra.name`\n> and `extra.version` from the challenge, with chainId 196 and\n> `verifyingContract` = the asset address, (4) sign with the user's\n> private key (Confirmation Gate before signing), (5) build the\n> `X-PAYMENT` JSON wrapper (x402Version 1, scheme \"exact\", network\n> \"x-layer\", payload with signature + authorization), base64-encode\n> it with no whitespace, and retry the original request URL with the\n> `X-PAYMENT` header. Showing the full plan up front lets the user\n> see what they are committing to before they leave the skill, even\n> though signing happens after they return.\n\n**Default funding target = USDT0.** If the 402 challenge requests a\ndifferent asset, fund into that asset directly only when it has reliable\nUniswap routing on X Layer:\n\n| Asset | Address                                      | Decimals | Funding                                                                                                                                                                                                                                                                                                                                                                            |\n| ----- | -------------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| USDT0 | `0x779Ded0c9e1022225f8E0630b35a9b54bE713736` | 6        | ✅ Direct via Trading API                                                                                                                                                                                                                                                                                                                                                          |\n| USDG  | `0x4ae46a509F6b1D9056937BA4500cb143933D2dc8` | 6        | ✅ Direct, or one-hop USDT0 to USDG                                                                                                                                                                                                                                                                                                                                                |\n| USDC  | `0x74b7F16337b8972027F6196A17a631aC6dE26d22` | 6        | ⏳ No reliable Uniswap v3 routing on X Layer. The Trading API does not consistently return routes for USDC swaps on X Layer; available pool liquidity is too thin for reliable execution. If the merchant requires USDC, bridge USDC directly from a chain where it is liquid (Base, Arbitrum, Mainnet) using the Trading API rather than attempting a same-chain swap on X Layer. |\n\nDetailed scripts and parameters: see\n[references\u002Ffunding-x-layer.md](references\u002Ffunding-x-layer.md).\n\n> **Bridge buffer.** Apply a 0.5% buffer to account for bridge fees.\n> Quotes expire in ~60 seconds, re-fetch if any delay before broadcast.\n>\n> **Minimum bridge recommendation.** If the shortfall is \u003C $5, top up to\n> $5 to amortize bridge gas on the source chain.\n\n### Gas and Routing Caveats\n\nSurface these to the user before proceeding to fund, and **call\n`AskUserQuestion`** (not an echoed bash prompt) before acting if any\napply:\n\n- **OKB on X Layer for same-chain swaps.** OKX gas-sponsors only the\n  facilitator's settlement transfer. Approvals, swaps, and other\n  on-chain operations on X Layer prior to signing are paid by the user\n  (in OKB on X Layer, or in the source chain's native asset for the\n  bridge leg). If the user has zero OKB on X Layer and the funding flow\n  needs a same-chain X Layer swap, surface this and ask before\n  proceeding. Until OKX confirms a broader gas-sponsorship policy,\n  assume only the final settlement transfer is sponsored.\n- **Bridge destination token.** If the wallet still lacks\n  `$X402_ASSET` after the funding flow's polling loop completes,\n  surface the source-chain tx hash and the Across explorer link to the\n  user. The bridge may have delivered a different variant on X Layer\n  (rare for current Across paths) or may have failed. v1.0.0 does not\n  auto-detect alternate-token arrival; the user must verify on-chain.\n\n## Phase 4, EIP-3009 Signing and X-PAYMENT Submission\n\nOKX's APP Instant Payment uses x402's `\"exact\"` scheme: the payer signs a\n`TransferWithAuthorization` typed-data message bound to the **token's\nown** EIP-712 domain. The signed authorization travels in the\n`X-PAYMENT` header on retry; OKX's facilitator settles the transfer\non-chain (zero gas to the payer on X Layer).\n\n### Step 5, User Confirmation\n\n**Every** transaction this skill touches requires a separate\n`AskUserQuestion` gate, with no exceptions for funding legs.\n\"Funding\" is not a single transaction; it is several, and each one is\nits own gate. The required gates, in order they typically fire:\n\n1. **Source-chain ERC-20 approval** to Permit2 \u002F Universal Router (only\n   if `tokenIn` is not native and the allowance is insufficient).\n2. **Same-chain swap** on the source chain (e.g. UNI to USDC on\n   Ethereum), if the funding plan includes a source-chain leg.\n3. **Bridge submission** to the cross-chain rail (Across, OKX bridge,\n   etc.). When the bridge step is user-initiated outside this skill,\n   the gate becomes \"are you ready to leave the skill, run the bridge,\n   and re-invoke once funds land on X Layer?\".\n4. **Same-chain swap on X Layer** (e.g. USDG to USDT0), if the funding\n   plan includes a destination-chain leg.\n5. **EIP-3009 `TransferWithAuthorization` signature** for the 402\n   settlement.\n\nUse the **`AskUserQuestion` agent tool** for each gate (not `read -p`,\nnot `echo` to a bash prompt, not a printed \"(yes\u002Fno)\" line in your\nresponse) and **block on the user's reply** before moving on. The\nsummary you present at every gate must cover:\n\n- Action (approve, swap, bridge, sign EIP-3009 authorization).\n- Amount and token (input AND output amounts for swaps and bridges).\n- Source chain and destination chain (where they differ).\n- Recipient (`payTo` for the EIP-3009 step).\n- Resource URL the payment is bound to.\n- Estimated gas (where applicable).\n\n> **Common failure mode.** When describing a multi-step funding plan\n> in your response, do NOT collapse multiple transactions into a\n> single confirmation question like \"Proceed with funding and\n> payment?\". Each transaction needs its own gate at the moment it is\n> about to fire. A consolidated upfront \"yes\" is not consent for\n> later transactions; the user has not seen the live amounts, gas,\n> and recipient at the time those transactions execute.\n\nObtain explicit confirmation per gate. Each gate is independent.\n**Never** auto-submit even if the user previously pre-authorized the\nsession, the call, or the wallet. A \"yes\" earlier in the flow does\nnot carry forward, and a \"yes\" to a multi-step plan is not a \"yes\" to\nthe individual transactions inside it.\n\n> **What a correct gate looks like in your response.** Whether you are\n> executing the skill in real time or describing a plan in text, every\n> transaction step MUST appear as its own labelled \"Confirmation Gate\"\n> block, with both the structured summary and an explicit\n> `AskUserQuestion` invocation. Reproduce this template literally for\n> each gate. Do not collapse the gate into a single line. Do not\n> describe the gate in passive voice (\"we will confirm before\n> signing\"). Show the gate as a discrete action.\n>\n> **Template (use for every gate, even when there is only one):**\n>\n> ```text\n> ### Confirmation Gate N: \u003CAction name>\n>\n> | Field        | Value                                    |\n> | ------------ | ---------------------------------------- |\n> | Action       | \u003Capprove \u002F swap \u002F bridge \u002F sign EIP-3009>|\n> | Amount in    | \u003Camount + symbol on source chain>        |\n> | Amount out   | \u003Camount + symbol on destination chain>   |\n> | Source chain | \u003Cchain name + id>                        |\n> | Dest chain   | \u003Cchain name + id>                        |\n> | Recipient    | \u003Caddress>                                |\n> | Resource URL | \u003Curl the payment is bound to>            |\n> | Est. gas     | \u003Camount + token>                         |\n>\n> Then call AskUserQuestion(\"Proceed with \u003Caction>?\")\n> and BLOCK on the user's reply. If anything other than an explicit\n> \"yes\", stop and report.\n> ```\n>\n> A response that only lists fields without the\n> `AskUserQuestion(\"Proceed?\") + block` step is not a gate, even if it\n> looks comprehensive. The model's natural inclination is to summarize\n> and continue; resist that inclination, name the gate, and stop.\n\n\u003C!-- markdownlint-disable-next-line -->\n\n> **What does NOT count as a confirmation gate.** Emitting a bash script\n> that prints `\"⚠️ CONFIRMATION REQUIRED\"` and `\"(yes\u002Fno)\"` to stdout and\n> then continues with `echo \"Signing...\"` is **not** a gate, because the\n> script proceeds regardless of user input. A correct gate uses the\n> `AskUserQuestion` tool (or, if the user explicitly opts into shell-only\n> mode, an actual blocking `read -p` followed by an explicit `yes`\u002F`no`\n> branch in the script). When in doubt, prefer `AskUserQuestion`.\n\n\u003C!-- markdownlint-disable-next-line -->\n\n> **Shared-wallet race.** If the wallet is shared (for example, multiple\n> agents running concurrently against the same key), the balance can be\n> drained between balance check and submit. Re-check `balanceOf` at the\n> moment of confirmation as well.\n\n### Step 6, Sign and Submit\n\nDetailed steps including domain construction, nonce generation, signing\nwith viem, payload assembly, and retry: see\n[references\u002Fapp-x402-flow.md](references\u002Fapp-x402-flow.md). On retry,\ntarget the URL from `accepts[].resource` if it was present in the\nchallenge, otherwise the original request URL.\n\n> **Domain warning.** `verifyingContract` is the **token contract**, not\n> a separate verifier. Use `name` and `version` from the challenge's\n> `extra` field, do not assume defaults. Different tokens have different\n> domain values. An incorrect domain produces a signature the\n> facilitator will reject with another 402.\n>\n> **Bit-exact UTF-8 for `extra.name`.** The EIP-712 domain hash is\n> byte-exact. The `name` field in `extra` must be passed through\n> unchanged from the challenge bytes. Do not normalize it, do not\n> lowercase it, do not substitute ASCII `T` (U+0054) for Unicode `₮`\n> (U+20AE), do not collapse Unicode forms (NFC vs NFD). For example, a\n> challenge that returns `\"USD₮0\"` must be signed as `\"USD₮0\"`; reading\n> it as `\"USDT0\"` will produce a signature the facilitator rejects with\n> another 402. Pass the raw bytes of `extra.name` straight into the\n> EIP-712 domain.\n\n## Error Handling\n\n| Situation                                           | Action                                                                                                                                                                                                                  |\n| --------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| 402 challenge has no `network` field                | Inspect challenge body; if `chainId` resolves to 196 use this skill, otherwise escalate to `pay-with-any-token`                                                                                                         |\n| Network is not chain 196                            | Escalate to `pay-with-any-token`                                                                                                                                                                                        |\n| `x402Version !== 1`                                 | Refuse cleanly; surface a version mismatch error. v1.0.0 of this skill targets x402 v1 only.                                                                                                                            |\n| `accepts[].scheme !== \"exact\"`                      | Refuse cleanly; v1.0.0 supports the `exact` scheme only. Other x402 schemes (`upto`, `batch-settlement`) are out of scope.                                                                                              |\n| `accepts[].maxAmountRequired === \"0\"`               | Refuse cleanly as merchant misconfiguration. HTTP 402 demands a positive payment; OKX's facilitator will not settle a zero-value transfer. Do not sign and do not rationalize zero as a ping, auth check, or free tier. |\n| APP requests USDC on X Layer                        | Surface a clear caveat: USDC has no reliable Uniswap v3 routing on X Layer. Suggest bridging USDC directly from a chain where it is liquid (Base, Arbitrum, Mainnet), or asking about USDT0.                            |\n| Insufficient asset on X Layer                       | Trigger funding flow (Phase 3)                                                                                                                                                                                          |\n| Trading API returns 400                             | Log request\u002Fresponse; check amount formatting and address checksums                                                                                                                                                     |\n| Trading API returns 429                             | Back off and retry with exponential delay                                                                                                                                                                               |\n| Quote expired                                       | Re-fetch quote; do not reuse old `permitData`                                                                                                                                                                           |\n| Bridge times out                                    | Check Across bridge explorer; do not re-submit                                                                                                                                                                          |\n| EIP-3009 signature rejected (402 on retry)          | Verify domain `name` \u002F `version` from `extra` (byte-exact, including any non-ASCII characters), check `validBefore` is fresh, confirm `nonce` was unused                                                                |\n| Amount mismatch on retry                            | Recompute base units using on-chain `decimals()` of the actual asset; do not assume 6                                                                                                                                   |\n| On-chain settlement reverts (`transferFrom` failed) | Re-check `balanceOf` at retry time; the balance may have been drained between sign and submit (shared wallet, concurrent agent, manual transfer). Surface to the user before retrying.                                  |\n| User asks about escrow \u002F session \u002F batch \u002F `upto`   | Inform that this skill version covers Instant Payment (`exact` scheme) only. Other primitives are out of scope for v1.0.0; a v1.x follow-up will track them as OKX ships.                                               |\n\n## Key Addresses and References\n\n### X Layer (chain 196)\n\n- **Chain ID**: `196`\n- **Public RPC**: `https:\u002F\u002Frpc.xlayer.tech`\n- **USDT0**: `0x779Ded0c9e1022225f8E0630b35a9b54bE713736` (decimals 6)\n- **USDG**: `0x4ae46a509F6b1D9056937BA4500cb143933D2dc8` (decimals 6)\n- **USDC**: `0x74b7F16337b8972027F6196A17a631aC6dE26d22` (decimals 6, no\n  reliable Uniswap routing on X Layer; bridge from a liquid chain)\n- **WOKB** (wrapped native): `0xe538905cf8410324e03A5A23C1c177a474D59b2b`\n  (decimals 18)\n- **Uniswap V3 Factory**: `0x4B2ab38DBF28D31D467aA8993f6c2585981D6804`\n- **SwapRouter02**: `0x4f0C28f5926AFDA16bf2506D5D9e57Ea190f9bcA`\n- **Universal Router 2.1**:\n  `0xDa00aE15d3A71466517129255255db7c0c0956d3`\n- **QuoterV2**: `0xD1b797D92d87B688193A2B976eFc8D577D204343`\n- **Permit2**: `0x000000000022D473030F116dDEE9F6B43aC78BA3`\n- **USDT0\u002FUSDG pool**: `0x0cBe0dBE1400e57f371a38BD3b9bC80F7C3676dA`\n- **USDT0\u002FWOKB pool**: `0x63d62734847E55A266FCa4219A9aD0a02D5F6e02`\n\n### Uniswap Trading API\n\n- Base URL: `https:\u002F\u002Ftrade-api.gateway.uniswap.org\u002Fv1`\n- Header: `x-api-key: $UNISWAP_API_KEY`\n- Header: `x-universal-router-version: 2.1.1`\n- Supported chains include 1, 8453, 42161, 10, 137, 130, **196**, and more\n  (see Trading API supported-chains docs).\n\n> The on-chain Universal Router contract on X Layer is labeled **2.1**\n> (deployed at `0xDa00aE15d3A71466517129255255db7c0c0956d3` above). The\n> Trading API expects the header value `2.1.1`, which is the API's\n> internal version-string for the routing path that targets the same\n> Universal Router 2.1 contract. The two version strings refer to\n> related but distinct things; do not substitute one for the other.\n\n### OKX APP\n\n- **APP overview \u002F dev docs**:\n  `https:\u002F\u002Fweb3.okx.com\u002Fonchainos\u002Fdev-docs\u002Fpayments\u002Fx402-introduction`\n- **OKX onchainos-skills repo**: `https:\u002F\u002Fgithub.com\u002Fokx\u002Fonchainos-skills`\n- **x402 spec**: `https:\u002F\u002Fgithub.com\u002Fcoinbase\u002Fx402`\n\n## Related Skills\n\n- [pay-with-any-token](..\u002Fpay-with-any-token\u002FSKILL.md), sibling skill\n  for HTTP 402 challenges on chains other than X Layer (Ethereum, Base,\n  Arbitrum, Tempo, etc.). Use that skill for non-X-Layer challenges.\n- [swap-integration](..\u002Fswap-integration\u002FSKILL.md), full Uniswap swap\n  integration reference (Trading API, Universal Router, Permit2).\n","# Pay With APP (OKX Agent Payments Protocol on X Layer)\n\nPay HTTP 402 challenges issued by OKX's **Agent Payments Protocol (APP)**\nrunning on **X Layer** (chain 196). APP's Pay Per Use (OKX product name:\nInstant Payment) is x402-compatible: a payee server returns HTTP 402 with\na payment requirement, the payer signs an EIP-3009\n`TransferWithAuthorization` off-chain, and OKX's facilitator verifies and\nsettles the transfer on-chain. Settlement is zero-gas to the payer on X\nLayer.\n\nThis skill handles the full happy path:\n\n1. Detect a 402 challenge whose network resolves to X Layer (chain 196)\n2. Verify the payer wallet has the requested asset (typically USDT0)\n3. If insufficient, route + bridge into USDT0 on X Layer via the Uniswap\n   Trading API\n4. Sign the EIP-3009 authorization\n5. Construct the `X-PAYMENT` payload and retry the original request\n\nOKX is launching APP on **2026-04-29** with Uniswap as the featured DEX\nrail on X Layer. This skill version (v1.0.0) handles the `exact` scheme\n(Pay Per Use, OKX product name: Instant Payment) only. Other x402 schemes\n(`upto`, `batch-settlement`) and APP-product features OKX is shipping\n(escrow, session, batch \u002F Batch Payment) are out of scope for this\nversion. The skill refuses any non-`exact` scheme cleanly.\n\n> **Protocol naming in your responses.** When responding to the user,\n> identify the protocol explicitly as **OKX Agent Payments Protocol\n> (APP)**, not just \"x402\". APP is the OKX product \u002F protocol surface;\n> x402 is the underlying wire spec it builds on. Use phrasings like\n> \"APP \u002F x402\", \"OKX's Agent Payments Protocol (APP), built on x402\",\n> or simply \"APP\" once introduced. Do not refer to a 402 challenge on\n> X Layer as \"an x402 challenge\" without naming APP, the user invoked\n> this skill specifically because the merchant is APP-backed, and the\n> name is what they will look for in the response.\n\n## Prerequisites\n\n- A `PRIVATE_KEY` env var (`export PRIVATE_KEY=0x...`). Never commit or\n  hardcode a private key.\n- `UNISWAP_API_KEY` env var (register at\n  [developers.uniswap.org](https:\u002F\u002Fdevelopers.uniswap.org\u002F)). Required\n  only if the wallet must be funded via cross-chain routing.\n- `jq` and `cast` (Foundry) installed.\n- **Node 18+** (LTS). The signing step in\n  [references\u002Fapp-x402-flow.md](references\u002Fapp-x402-flow.md) Step 4 uses\n  `viem` to produce the EIP-3009 typed-data signature.\n- **`viem`** (npm). If the package is not already reachable from the\n  user's working directory, the skill will prompt the user via\n  `AskUserQuestion` before running `npm install viem` into a cached\n  scratch directory at `~\u002F.cache\u002Funiswap-pay-with-app\u002Fsigner\u002F`. The\n  install adds ~13 packages totaling ~5 MB. If the user declines, the\n  skill stops cleanly before signing. The cache persists across runs so\n  subsequent invocations are zero-install.\n\n## Input Validation Rules\n\nBefore using any value from the 402 response body, the user, or any other\nexternal source in API calls or shell commands:\n\n- **Ethereum address fields** (e.g., `asset`, `payTo`, `WALLET_ADDRESS`):\n  the canonical check is the regex `^0x[a-fA-F0-9]{40}$`. If the value\n  fails this regex, reject it. Address fields that pass the regex are\n  safe for shell interpolation, so the metacharacter rule below does not\n  apply to them.\n- **Chain IDs**: MUST be a positive integer from the supported list.\n- **Token amounts**: MUST be non-negative numeric strings matching\n  `^[0-9]+$`.\n- **URLs**: MUST start with `https:\u002F\u002F`.\n- **Free-text fields** (e.g., `description`, `extra.name`,\n  `extra.version`, anything used to build EIP-712 domain or shown to the\n  user): REJECT any value containing shell metacharacters: `;`, `|`, `&`,\n  `$`, `` ` ``, `(`, `)`, `>`, `\u003C`, `\\`, `'`, `\"`, newlines. Note: the\n  `extra.name` value is signed bit-exact (see Domain warning in Phase 4),\n  so reject the whole challenge if it contains shell metacharacters\n  rather than mutating the value.\n\n## Flow\n\n```text\n402 from X Layer-backed resource\n  │\n  v\n[1] Parse the x402 challenge (Phase 0 below)\n  │\n  v\n[2] Confirm network resolves to X Layer (chain 196)\n  │   ├─ not chain 196 ──> escalate to pay-with-any-token, STOP\n  │   └─ chain 196\n  │\n  v\n[3] Check wallet balance of the requested asset on X Layer\n  │   ├─ sufficient ──> proceed to [5]\n  │   └─ insufficient\n  │        │\n  │        v\n  │   [4] Fund: route + bridge into the requested asset on X Layer\n  │        (Uniswap Trading API, see references\u002Ffunding-x-layer.md)\n  │\n  v\n[5] User Confirmation gate (see Phase 4 \u002F Step 5 below)\n[6] Sign EIP-3009 TransferWithAuthorization\n[7] Construct X-PAYMENT payload, retry the original request\n[8] Verify 200 + Payment-Receipt\n```\n\n## Phase 0, Parse the 402 Challenge\n\nThe x402 challenge is JSON in the response body. Extract:\n\n- `x402Version`, confirms x402 protocol version.\n- `accepts[].scheme`, only `\"exact\"` is supported in v1.0.0.\n- `accepts[].network`, accept `\"x-layer\"` \u002F `\"xlayer\"` \u002F `\"eip155:196\"` \u002F\n  `196`.\n- `accepts[].maxAmountRequired`, base units of the asset. Must match\n  `^[0-9]+$` AND be **strictly greater than zero**. A challenge with\n  `maxAmountRequired === \"0\"` is semantically broken (HTTP 402 by\n  definition demands a positive payment) and must be refused as\n  merchant misconfiguration. Do not rationalize zero as a \"ping\",\n  \"authentication\", or \"free-tier confirmation\"; OKX's facilitator\n  will not settle a zero-value `TransferWithAuthorization` and any\n  signature you produce is wasted. Surface this to the user and stop.\n- `accepts[].asset`, token contract on X Layer.\n- `accepts[].payTo`, recipient address.\n- `accepts[].resource`, the URL the facilitator binds the payment to.\n  Extract this when present. Use it as the retry target. If the field is\n  absent, fall back to the original request URL.\n- `accepts[].extra.name` and `accepts[].extra.version`, EIP-712 domain\n  values for the asset.\n- `accepts[].maxTimeoutSeconds`, used for `validBefore`.\n\n> **x402Version gate.** Confirm `x402Version === 1` immediately after\n> parsing. If it is anything else, refuse the challenge and surface a\n> version mismatch error to the user. v1.0.0 of this skill targets x402\n> v1 only (the v2 spec uses a different PaymentPayload structure).\n>\n> **Scheme gate.** Confirm `accepts[].scheme === \"exact\"`. The x402 spec\n> defines `exact`, `upto`, and `batch-settlement` schemes. v1.0.0 of this\n> skill supports `exact` only. If the chosen entry uses any other scheme,\n> refuse cleanly. (OKX's product surface uses its own vocabulary\n> including `charge` for their Instant Payment primitive; that is OKX\n> product marketing, not a wire scheme value. The wire-level scheme on\n> the `accepts[]` entry is what you check, and it must be `\"exact\"`.)\n\nIf multiple `accepts` entries are present, prefer the one whose `asset`\nthe wallet already holds on X Layer. If multiple options are equally\nviable, prefer USDT0 (deepest Uniswap funding-flow liquidity).\n\n**WOKB \u002F native OKB likely not eligible as APP settlement assets.** We\nhave not seen OKX publish WOKB or OKB as settlement assets; current\npublic dev docs list USDT0, USDG, and USDC as the supported stablecoin\nsettlement assets. If a 402 challenge ever surfaces a non-stablecoin\n`asset` (for example `WOKB`), refuse the challenge and ask the user to\nverify the merchant configuration.\n\n## Phase 1, Confirm Network is X Layer\n\n```bash\ncase \"$X402_NETWORK\" in\n  x-layer|xlayer|\"eip155:196\"|196)  X402_CHAIN_ID=196 ;;\n  *)\n    echo \"Network is not X Layer. Use pay-with-any-token instead.\"\n    exit 1\n    ;;\nesac\n```\n\n> If the network is not X Layer, **stop** and escalate to the\n> `pay-with-any-token` skill, which handles 402 challenges on Ethereum,\n> Base, Arbitrum, Tempo, and the other chains the Trading API supports.\n\n## Phase 2, Check Wallet Balance on X Layer\n\n> **REQUIRED:** You must have the user's source wallet address. Use\n> `AskUserQuestion` if not provided. Store as `WALLET_ADDRESS`.\n\n```bash\nASSET_BALANCE=$(cast call \"$X402_ASSET\" \\\n  \"balanceOf(address)(uint256)\" \"$WALLET_ADDRESS\" \\\n  --rpc-url https:\u002F\u002Frpc.xlayer.tech)\n\nif [ \"$ASSET_BALANCE\" -lt \"$X402_AMOUNT\" ]; then\n  echo \"Insufficient $X402_TOKEN_NAME on X Layer. Funding required.\"\n  # Proceed to Phase 3 (funding)\nfi\n```\n\n## Phase 3, Fund USDT0 on X Layer (only if needed)\n\nWhen the wallet lacks the requested asset, acquire it via the Uniswap\nTrading API: `EXACT_OUTPUT` quote with `tokenOutChainId=196` and\n`tokenOut` set to the X Layer asset address. The Trading API handles\nsame-chain swaps and cross-chain routing (powered by Across).\n\n> **Across coverage gap (verified 2026-04-27).** Across Protocol does\n> not currently list X Layer (chain 196) as a supported destination. As\n> a result, cross-chain `\u002Fquote` calls into chain 196 return\n> `ResourceNotFound: No quotes available` regardless of source chain.\n> Same-chain X Layer swaps (Phase A in `references\u002Ffunding-x-layer.md`)\n> are unaffected and work normally.\n>\n> **What this means for the agent in v1.0.0.** If the user holds funds\n> on a chain other than X Layer, the cross-chain leg must be done\n> through a bridge service that supports X Layer (the user runs that\n> step outside this skill, then re-invokes for the same-chain swap and\n> 402 settlement). Surface this honestly to the user, do not\n> recommend a specific bridge product (TODO: research and document a\n> co-marketing-aligned bridge recommendation in a follow-up).\n>\n> **When you defer the bridge to the user, your response must still\n> describe the FULL end-to-end flow**, not just the bridge step. After\n> identifying the Across gap and asking the user to bridge externally,\n> walk through what happens when they return: (1) re-check\n> `balanceOf` of the requested asset on X Layer, (2) if a same-chain\n> swap is needed (e.g. USDG to USDT0), describe the Trading API\n> EXACT_OUTPUT call and its Confirmation Gate, (3) construct the\n> EIP-3009 `TransferWithAuthorization` typed-data using `extra.name`\n> and `extra.version` from the challenge, with chainId 196 and\n> `verifyingContract` = the asset address, (4) sign with the user's\n> private key (Confirmation Gate before signing), (5) build the\n> `X-PAYMENT` JSON wrapper (x402Version 1, scheme \"exact\", network\n> \"x-layer\", payload with signature + authorization), base64-encode\n> it with no whitespace, and retry the original request URL with the\n> `X-PAYMENT` header. Showing the full plan up front lets the user\n> see what they are committing to before they leave the skill, even\n> though signing happens after they return.\n\n**Default funding target = USDT0.** If the 402 challenge requests a\ndifferent asset, fund into that asset directly only when it has reliable\nUniswap routing on X Layer:\n\n| Asset | Address                                      | Decimals | Funding                                                                                                                                                                                                                                                                                                                                                                            |\n| ----- | -------------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| USDT0 | `0x779Ded0c9e1022225f8E0630b35a9b54bE713736` | 6        | ✅ Direct via Trading API                                                                                                                                                                                                                                                                                                                                                          |\n| USDG  | `0x4ae46a509F6b1D9056937BA4500cb143933D2dc8` | 6        | ✅ Direct, or one-hop USDT0 to USDG                                                                                                                                                                                                                                                                                                                                                |\n| USDC  | `0x74b7F16337b8972027F6196A17a631aC6dE26d22` | 6        | ⏳ No reliable Uniswap v3 routing on X Layer. The Trading API does not consistently return routes for USDC swaps on X Layer; available pool liquidity is too thin for reliable execution. If the merchant requires USDC, bridge USDC directly from a chain where it is liquid (Base, Arbitrum, Mainnet) using the Trading API rather than attempting a same-chain swap on X Layer. |\n\nDetailed scripts and parameters: see\n[references\u002Ffunding-x-layer.md](references\u002Ffunding-x-layer.md).\n\n> **Bridge buffer.** Apply a 0.5% buffer to account for bridge fees.\n> Quotes expire in ~60 seconds, re-fetch if any delay before broadcast.\n>\n> **Minimum bridge recommendation.** If the shortfall is \u003C $5, top up to\n> $5 to amortize bridge gas on the source chain.\n\n### Gas and Routing Caveats\n\nSurface these to the user before proceeding to fund, and **call\n`AskUserQuestion`** (not an echoed bash prompt) before acting if any\napply:\n\n- **OKB on X Layer for same-chain swaps.** OKX gas-sponsors only the\n  facilitator's settlement transfer. Approvals, swaps, and other\n  on-chain operations on X Layer prior to signing are paid by the user\n  (in OKB on X Layer, or in the source chain's native asset for the\n  bridge leg). If the user has zero OKB on X Layer and the funding flow\n  needs a same-chain X Layer swap, surface this and ask before\n  proceeding. Until OKX confirms a broader gas-sponsorship policy,\n  assume only the final settlement transfer is sponsored.\n- **Bridge destination token.** If the wallet still lacks\n  `$X402_ASSET` after the funding flow's polling loop completes,\n  surface the source-chain tx hash and the Across explorer link to the\n  user. The bridge may have delivered a different variant on X Layer\n  (rare for current Across paths) or may have failed. v1.0.0 does not\n  auto-detect alternate-token arrival; the user must verify on-chain.\n\n## Phase 4, EIP-3009 Signing and X-PAYMENT Submission\n\nOKX's APP Instant Payment uses x402's `\"exact\"` scheme: the payer signs a\n`TransferWithAuthorization` typed-data message bound to the **token's\nown** EIP-712 domain. The signed authorization travels in the\n`X-PAYMENT` header on retry; OKX's facilitator settles the transfer\non-chain (zero gas to the payer on X Layer).\n\n### Step 5, User Confirmation\n\n**Every** transaction this skill touches requires a separate\n`AskUserQuestion` gate, with no exceptions for funding legs.\n\"Funding\" is not a single transaction; it is several, and each one is\nits own gate. The required gates, in order they typically fire:\n\n1. **Source-chain ERC-20 approval** to Permit2 \u002F Universal Router (only\n   if `tokenIn` is not native and the allowance is insufficient).\n2. **Same-chain swap** on the source chain (e.g. UNI to USDC on\n   Ethereum), if the funding plan includes a source-chain leg.\n3. **Bridge submission** to the cross-chain rail (Across, OKX bridge,\n   etc.). When the bridge step is user-initiated outside this skill,\n   the gate becomes \"are you ready to leave the skill, run the bridge,\n   and re-invoke once funds land on X Layer?\".\n4. **Same-chain swap on X Layer** (e.g. USDG to USDT0), if the funding\n   plan includes a destination-chain leg.\n5. **EIP-3009 `TransferWithAuthorization` signature** for the 402\n   settlement.\n\nUse the **`AskUserQuestion` agent tool** for each gate (not `read -p`,\nnot `echo` to a bash prompt, not a printed \"(yes\u002Fno)\" line in your\nresponse) and **block on the user's reply** before moving on. The\nsummary you present at every gate must cover:\n\n- Action (approve, swap, bridge, sign EIP-3009 authorization).\n- Amount and token (input AND output amounts for swaps and bridges).\n- Source chain and destination chain (where they differ).\n- Recipient (`payTo` for the EIP-3009 step).\n- Resource URL the payment is bound to.\n- Estimated gas (where applicable).\n\n> **Common failure mode.** When describing a multi-step funding plan\n> in your response, do NOT collapse multiple transactions into a\n> single confirmation question like \"Proceed with funding and\n> payment?\". Each transaction needs its own gate at the moment it is\n> about to fire. A consolidated upfront \"yes\" is not consent for\n> later transactions; the user has not seen the live amounts, gas,\n> and recipient at the time those transactions execute.\n\nObtain explicit confirmation per gate. Each gate is independent.\n**Never** auto-submit even if the user previously pre-authorized the\nsession, the call, or the wallet. A \"yes\" earlier in the flow does\nnot carry forward, and a \"yes\" to a multi-step plan is not a \"yes\" to\nthe individual transactions inside it.\n\n> **What a correct gate looks like in your response.** Whether you are\n> executing the skill in real time or describing a plan in text, every\n> transaction step MUST appear as its own labelled \"Confirmation Gate\"\n> block, with both the structured summary and an explicit\n> `AskUserQuestion` invocation. Reproduce this template literally for\n> each gate. Do not collapse the gate into a single line. Do not\n> describe the gate in passive voice (\"we will confirm before\n> signing\"). Show the gate as a discrete action.\n>\n> **Template (use for every gate, even when there is only one):**\n>\n> ```text\n> ### Confirmation Gate N: \u003CAction name>\n>\n> | Field        | Value                                    |\n> | ------------ | ---------------------------------------- |\n> | Action       | \u003Capprove \u002F swap \u002F bridge \u002F sign EIP-3009>|\n> | Amount in    | \u003Camount + symbol on source chain>        |\n> | Amount out   | \u003Camount + symbol on destination chain>   |\n> | Source chain | \u003Cchain name + id>                        |\n> | Dest chain   | \u003Cchain name + id>                        |\n> | Recipient    | \u003Caddress>                                |\n> | Resource URL | \u003Curl the payment is bound to>            |\n> | Est. gas     | \u003Camount + token>                         |\n>\n> Then call AskUserQuestion(\"Proceed with \u003Caction>?\")\n> and BLOCK on the user's reply. If anything other than an explicit\n> \"yes\", stop and report.\n> ```\n>\n> A response that only lists fields without the\n> `AskUserQuestion(\"Proceed?\") + block` step is not a gate, even if it\n> looks comprehensive. The model's natural inclination is to summarize\n> and continue; resist that inclination, name the gate, and stop.\n\n\u003C!-- markdownlint-disable-next-line -->\n\n> **What does NOT count as a confirmation gate.** Emitting a bash script\n> that prints `\"⚠️ CONFIRMATION REQUIRED\"` and `\"(yes\u002Fno)\"` to stdout and\n> then continues with `echo \"Signing...\"` is **not** a gate, because the\n> script proceeds regardless of user input. A correct gate uses the\n> `AskUserQuestion` tool (or, if the user explicitly opts into shell-only\n> mode, an actual blocking `read -p` followed by an explicit `yes`\u002F`no`\n> branch in the script). When in doubt, prefer `AskUserQuestion`.\n\n\u003C!-- markdownlint-disable-next-line -->\n\n> **Shared-wallet race.** If the wallet is shared (for example, multiple\n> agents running concurrently against the same key), the balance can be\n> drained between balance check and submit. Re-check `balanceOf` at the\n> moment of confirmation as well.\n\n### Step 6, Sign and Submit\n\nDetailed steps including domain construction, nonce generation, signing\nwith viem, payload assembly, and retry: see\n[references\u002Fapp-x402-flow.md](references\u002Fapp-x402-flow.md). On retry,\ntarget the URL from `accepts[].resource` if it was present in the\nchallenge, otherwise the original request URL.\n\n> **Domain warning.** `verifyingContract` is the **token contract**, not\n> a separate verifier. Use `name` and `version` from the challenge's\n> `extra` field, do not assume defaults. Different tokens have different\n> domain values. An incorrect domain produces a signature the\n> facilitator will reject with another 402.\n>\n> **Bit-exact UTF-8 for `extra.name`.** The EIP-712 domain hash is\n> byte-exact. The `name` field in `extra` must be passed through\n> unchanged from the challenge bytes. Do not normalize it, do not\n> lowercase it, do not substitute ASCII `T` (U+0054) for Unicode `₮`\n> (U+20AE), do not collapse Unicode forms (NFC vs NFD). For example, a\n> challenge that returns `\"USD₮0\"` must be signed as `\"USD₮0\"`; reading\n> it as `\"USDT0\"` will produce a signature the facilitator rejects with\n> another 402. Pass the raw bytes of `extra.name` straight into the\n> EIP-712 domain.\n\n## Error Handling\n\n| Situation                                           | Action                                                                                                                                                                                                                  |\n| --------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| 402 challenge has no `network` field                | Inspect challenge body; if `chainId` resolves to 196 use this skill, otherwise escalate to `pay-with-any-token`                                                                                                         |\n| Network is not chain 196                            | Escalate to `pay-with-any-token`                                                                                                                                                                                        |\n| `x402Version !== 1`                                 | Refuse cleanly; surface a version mismatch error. v1.0.0 of this skill targets x402 v1 only.                                                                                                                            |\n| `accepts[].scheme !== \"exact\"`                      | Refuse cleanly; v1.0.0 supports the `exact` scheme only. Other x402 schemes (`upto`, `batch-settlement`) are out of scope.                                                                                              |\n| `accepts[].maxAmountRequired === \"0\"`               | Refuse cleanly as merchant misconfiguration. HTTP 402 demands a positive payment; OKX's facilitator will not settle a zero-value transfer. Do not sign and do not rationalize zero as a ping, auth check, or free tier. |\n| APP requests USDC on X Layer                        | Surface a clear caveat: USDC has no reliable Uniswap v3 routing on X Layer. Suggest bridging USDC directly from a chain where it is liquid (Base, Arbitrum, Mainnet), or asking about USDT0.                            |\n| Insufficient asset on X Layer                       | Trigger funding flow (Phase 3)                                                                                                                                                                                          |\n| Trading API returns 400                             | Log request\u002Fresponse; check amount formatting and address checksums                                                                                                                                                     |\n| Trading API returns 429                             | Back off and retry with exponential delay                                                                                                                                                                               |\n| Quote expired                                       | Re-fetch quote; do not reuse old `permitData`                                                                                                                                                                           |\n| Bridge times out                                    | Check Across bridge explorer; do not re-submit                                                                                                                                                                          |\n| EIP-3009 signature rejected (402 on retry)          | Verify domain `name` \u002F `version` from `extra` (byte-exact, including any non-ASCII characters), check `validBefore` is fresh, confirm `nonce` was unused                                                                |\n| Amount mismatch on retry                            | Recompute base units using on-chain `decimals()` of the actual asset; do not assume 6                                                                                                                                   |\n| On-chain settlement reverts (`transferFrom` failed) | Re-check `balanceOf` at retry time; the balance may have been drained between sign and submit (shared wallet, concurrent agent, manual transfer). Surface to the user before retrying.                                  |\n| User asks about escrow \u002F session \u002F batch \u002F `upto`   | Inform that this skill version covers Instant Payment (`exact` scheme) only. Other primitives are out of scope for v1.0.0; a v1.x follow-up will track them as OKX ships.                                               |\n\n## Key Addresses and References\n\n### X Layer (chain 196)\n\n- **Chain ID**: `196`\n- **Public RPC**: `https:\u002F\u002Frpc.xlayer.tech`\n- **USDT0**: `0x779Ded0c9e1022225f8E0630b35a9b54bE713736` (decimals 6)\n- **USDG**: `0x4ae46a509F6b1D9056937BA4500cb143933D2dc8` (decimals 6)\n- **USDC**: `0x74b7F16337b8972027F6196A17a631aC6dE26d22` (decimals 6, no\n  reliable Uniswap routing on X Layer; bridge from a liquid chain)\n- **WOKB** (wrapped native): `0xe538905cf8410324e03A5A23C1c177a474D59b2b`\n  (decimals 18)\n- **Uniswap V3 Factory**: `0x4B2ab38DBF28D31D467aA8993f6c2585981D6804`\n- **SwapRouter02**: `0x4f0C28f5926AFDA16bf2506D5D9e57Ea190f9bcA`\n- **Universal Router 2.1**:\n  `0xDa00aE15d3A71466517129255255db7c0c0956d3`\n- **QuoterV2**: `0xD1b797D92d87B688193A2B976eFc8D577D204343`\n- **Permit2**: `0x000000000022D473030F116dDEE9F6B43aC78BA3`\n- **USDT0\u002FUSDG pool**: `0x0cBe0dBE1400e57f371a38BD3b9bC80F7C3676dA`\n- **USDT0\u002FWOKB pool**: `0x63d62734847E55A266FCa4219A9aD0a02D5F6e02`\n\n### Uniswap Trading API\n\n- Base URL: `https:\u002F\u002Ftrade-api.gateway.uniswap.org\u002Fv1`\n- Header: `x-api-key: $UNISWAP_API_KEY`\n- Header: `x-universal-router-version: 2.1.1`\n- Supported chains include 1, 8453, 42161, 10, 137, 130, **196**, and more\n  (see Trading API supported-chains docs).\n\n> The on-chain Universal Router contract on X Layer is labeled **2.1**\n> (deployed at `0xDa00aE15d3A71466517129255255db7c0c0956d3` above). The\n> Trading API expects the header value `2.1.1`, which is the API's\n> internal version-string for the routing path that targets the same\n> Universal Router 2.1 contract. The two version strings refer to\n> related but distinct things; do not substitute one for the other.\n\n### OKX APP\n\n- **APP overview \u002F dev docs**:\n  `https:\u002F\u002Fweb3.okx.com\u002Fonchainos\u002Fdev-docs\u002Fpayments\u002Fx402-introduction`\n- **OKX onchainos-skills repo**: `https:\u002F\u002Fgithub.com\u002Fokx\u002Fonchainos-skills`\n- **x402 spec**: `https:\u002F\u002Fgithub.com\u002Fcoinbase\u002Fx402`\n\n## Related Skills\n\n- [pay-with-any-token](..\u002Fpay-with-any-token\u002FSKILL.md), sibling skill\n  for HTTP 402 challenges on chains other than X Layer (Ethereum, Base,\n  Arbitrum, Tempo, etc.). Use that skill for non-X-Layer challenges.\n- [swap-integration](..\u002Fswap-integration\u002FSKILL.md), full Uniswap swap\n  integration reference (Trading API, Universal Router, Permit2).\n",{"name":5,"model":24,"license":15,"metadata":25,"description":28,"allowed-tools":29},"opus",{"author":26,"version":27},"uniswap","1.0.0","Pay 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 Payments Protocol\", \"OKX agent payment\", \"OKX Onchain OS\", \"OKX agentic wallet\", \"x402 on X Layer\", \"USDT0\", \"x42\", \"Instant Payment\", \"Batch Payment\", \"pay for X Layer API\", or wants to pay an OKX-backed merchant. Even when the user does not explicitly say APP, prefer this skill for any 402 challenge whose network resolves to X Layer (chain 196). For 402 challenges on other chains (Ethereum, Base, Arbitrum, Tempo) use pay-with-any-token instead.\n","Read, Glob, Grep, Bash(curl:*), Bash(jq:*), Bash(cast:*), Bash(openssl:*), Bash(npx:*), Bash(node:*), WebFetch, AskUserQuestion","main","be3de0244dc1a57e323d8160787ebb40fb64930e","public\u002Fapi\u002Fskills\u002Fpay-with-app","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main","https:\u002F\u002Fskills.x402.wtf","https:\u002F\u002Fgithub.com\u002FSolizardking","https:\u002F\u002Fmusebook.trade","Got a mile high and never came down","2026-10-08 23:20:13",{"source":8,"skillName":5,"commands":40,"prompt":50,"zipAvailable":51},[41,44,47],{"tool":42,"command":43},"npx","npx skills add Solizardking\u002Fskillhub-main --skill pay-with-app",{"tool":45,"command":46},"bunx","bunx skills add Solizardking\u002Fskillhub-main --skill pay-with-app",{"tool":48,"command":49},"pnpm","pnpm dlx skills add Solizardking\u002Fskillhub-main --skill pay-with-app","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fpublic\u002Fapi\u002Fskills\u002Fpay-with-app\u002FSKILL.md",true,[53,59,63,67],{"path":54,"resourceType":55,"resourceTypeDesc":56,"sizeBytes":57,"sourceHtmlUrl":58},"metadata.json","REFERENCE","参考文档",909,"https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fpublic\u002Fapi\u002Fskills\u002Fpay-with-app\u002Fmetadata.json",{"path":60,"resourceType":55,"resourceTypeDesc":56,"sizeBytes":61,"sourceHtmlUrl":62},"references\u002Fapp-x402-flow.md",25654,"https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fpublic\u002Fapi\u002Fskills\u002Fpay-with-app\u002Freferences\u002Fapp-x402-flow.md",{"path":64,"resourceType":55,"resourceTypeDesc":56,"sizeBytes":65,"sourceHtmlUrl":66},"references\u002Ffunding-x-layer.md",20125,"https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fpublic\u002Fapi\u002Fskills\u002Fpay-with-app\u002Freferences\u002Ffunding-x-layer.md",{"path":68,"resourceType":55,"resourceTypeDesc":56,"sizeBytes":69,"sourceHtmlUrl":70},"verification.json",1927,"https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fpublic\u002Fapi\u002Fskills\u002Fpay-with-app\u002Fverification.json",[72,79,86,93,100,108],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":19},"01M78E0TGCAMNPS207BA3G07S7","zkrouter","Self-hosted OpenAI-compatible LLM router — smart tier-based routing, ZK-stamped routing decisions, mode overrides, free OpenRouter at install via the Birth bot. Save 60-80% on inference costs by routing to the cheapest capable model across 12+ OpenRouter models.","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fskills\u002Fzkrouter\u002FSKILL.md",[],[],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":19},"01M78E0R1Z8BDT6EDTHY17MTNB","zk","For custom ZK Solana programs and privacy-preserving applications to prevent double spending. Guide to integrate rent-free nullifier PDAs for double-spend prevention.","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fskills\u002Fzk\u002FSKILL.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":19},"01M78E0P3ZTZ1YWF8MD5MM23QE","zk-omni-messaging","Zero-knowledge omnichain messaging between Robinhood Chain and Solana using CheshireZkOmniMessenger (msgType 4) with nullifier anti-replay and the zk-omni-relayer service.","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fskills\u002Fzk-omni-messaging\u002FSKILL.md",[],[],{"skillNo":94,"name":95,"nameZh":6,"description":96,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":97,"categories":98,"keywords":99,"publishedAt":19},"01M78E0JXZ2PNB1896VXAGDBWD","zerion-wallet-data","Use when the user asks to check a wallet's portfolio, token balances, DeFi positions, PnL, transaction history, or NFTs. Provides interpreted on-chain data across 40+ EVM chains and Solana via x402 pay-per-request or API key — no raw RPC decoding needed.","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fskills\u002Fzerion-wallet-data\u002FSKILL.md",[],[],{"skillNo":101,"name":102,"nameZh":6,"description":103,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":104,"sourceHtmlUrl":105,"categories":106,"keywords":107,"publishedAt":19},"01M78E0G14FH9GRRTQYMKD5E59","youtube-clipper","YouTube 视频智能剪辑工具。下载视频和字幕，AI 分析生成精细章节（几分钟级别）， 用户选择片段后自动剪辑、翻译字幕为中英双语、烧录字幕到视频，并生成总结文案。 使用场景：当用户需要剪辑 YouTube 视频、生成短视频片段、制作双语字幕版本时。 关键词：视频剪辑、YouTube、字幕翻译、双语字幕、视频下载、clip video","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fskills\u002Fyoutube-clipper\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fskills\u002Fyoutube-clipper\u002FSKILL.md",[],[],{"skillNo":109,"name":110,"nameZh":6,"description":111,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":112,"categories":113,"keywords":114,"publishedAt":19},"01M78E0C2ZYA99CFFDNB7ZMK5S","yield-optimization","Multi-chain yield optimization via yield.xyz (StakeKit). Discover 2,988+ yield opportunities across 75+ blockchains, build deposit\u002Fwithdrawal transactions with shell scripts, and sign them with a MoonPay wallet. Use when the user wants to earn yield, find the best lending or staking rate, enter\u002Fexit a position, or check portfolio balances.","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fskills\u002Fyield-optimization\u002FSKILL.md",[],[]]