Migrate x402 payment rail to the official OKX Payment SDK - #17
Merged
Conversation
CLV Scout was delisted from OKX.AI because its payment rail hand-rolled the x402 wire protocol instead of using the official SDK, so the marketplace could not verify it. Replace the hand-rolled rail with the published packages β mirroring the sibling EdgeLedger build that passed review. - deps: add @okxweb3/x402-express, @okxweb3/x402-core, @okxweb3/x402-evm - api/rails/okx.ts: okxPayGate() is now the SDK paymentMiddleware over an x402ResourceServer + server-side ExactEvmScheme + OKXFacilitatorClient; per-route pricing (grade $0.01, audit $0.20); warmFacilitator() boot check - api/rails/localFacilitator.ts (new): drop-in FacilitatorClient for no-cred mode β real EIP-712/EIP-3009 recovery, honest pending/local: settlement - api/server.ts: force Accept: application/json, mirror X-PAYMENT -> PAYMENT-SIGNATURE and PAYMENT-RESPONSE -> X-PAYMENT-RESPONSE, mirror the challenge into the 402 body; method-less gating so GET probes return 402 - api/main.ts: boot-time facilitator warm-up; routes.ts: recover payer from the payment header (SDK does not attach req.x402) - tests + docs updated to the SDK integration Verified: npm run ci green (lint + typecheck + 130/130 tests, 99.5% coverage); live server round-trip via scripts/buyer.ts returns HTTP 200 on both routes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
CLV Scout was delisted from OKX.AI β reason: "your service is not integrated with the official OKX Payment SDK, which prevents us from completing verification." The rail hand-rolled the x402 wire protocol with
viem+expressinstead of the published@okxweb3/x402-*packages.The live endpoint confirms this:
POST /api/gradestill returns the old hand-rolled challenge (error:"payment_required"), not the SDK's.What
Replace the hand-rolled rail with the official SDK, mirroring the sibling EdgeLedger build that passed review:
@okxweb3/x402-express,@okxweb3/x402-core,@okxweb3/x402-evmokxPayGate()= SDKpaymentMiddlewareoverx402ResourceServer+ server-sideExactEvmScheme+OKXFacilitatorClient; per-route pricing (grade $0.01, audit $0.20);warmFacilitator()boot checkFacilitatorClientfor no-cred mode β real EIP-712/EIP-3009 recovery, honestpending/local:settlementAccept: application/json, mirrorX-PAYMENTβPAYMENT-SIGNATUREandPAYMENT-RESPONSEβX-PAYMENT-RESPONSE, mirror challenge into 402 body; method-less gating so GET probes return 402req.x402)Verified
npm run cigreen β lint + typecheck + 130/130 tests, 99.5% coveragescripts/buyer.ts: 402 β EIP-3009 sign β SDK verify β settle β HTTP 200 on both routesDeploy note
Set
OKX_API_KEY/OKX_SECRET_KEY/OKX_PASSPHRASEin Railway env so production settles via the realOKXFacilitatorClient. Then resubmit the OKX.AI listing.