REST routes are gated by OKX's @okxweb3/app-x402-express middleware (x402 version 2, exact scheme).
The round trip
- Call the route without payment. It answers
402with a base64PAYMENT-REQUIREDheader listing what to pay: amount, asset, network andpayTo. - Sign an EIP-3009
TransferWithAuthorizationfor that amount of USD₮0. The EIP-712 domain is nameUSD₮0(with the ₮ character), version1, chain id 1952. - Retry the same request with the base64 payload in
PAYMENT-SIGNATURE. - The response carries the tool result, and
PAYMENT-RESPONSEholds the settlement receipt with its transaction hash.
curl -i "https://api.roundlot.0xo.in/v1/quote?symbol=NVDA&side=buy&size=100"
# HTTP/1.1 402 Payment Required
# PAYMENT-REQUIRED: eyJ4NDAyVmVyc2lvbiI6Mi...
Clients
Any x402 v2 client that signs EIP-3009 works, for example x402Client with ExactEvmScheme from @okxweb3/app-x402-core and @okxweb3/app-x402-evm, backed by a plain viem account.
Refunds you never need
Input is validated before payment is requested (a bad call gets 400, not 402), and settlement happens only after the tool returns 2xx. A refused call is never charged.