Payment API

Verify the transaction#

Verify the legitimacy of the transaction.

Request address#

POST https://web3.okx.com/api/v6/x402/verify

Request parameters#

ParameterTypeRequiredDescription
x402VersionStringYesVersion of the x402 protocol. For v1, pass integer 1
chainIndexStringYesUnique identifier of the blockchain
paymentPayloadObjectYesThe x402 payment payload carried by the client with the protected request
>x402VersionStringYesVersion of the x402 protocol. For v1, pass integer 1
>schemeStringYesSettlement scheme, e.g. exact (one‑time fixed‑amount payment)
>payloadObjectYesObject containing payment signature and authorization data
>>signatureStringYesCryptographic signature
>>authorizationObjectYesAuthorization information
>>>fromStringYesPayer address
>>>toStringYesPayee address
>>>valueStringYesPayment amount in the smallest on-chain unit (e.g. for USDT with 6 decimals, 1 USDT = 1000000)
>>>validAfterStringYesUnix timestamp (seconds) after which the authorization becomes valid
>>>validBeforeStringYesUnix timestamp (seconds) before which the authorization is valid (expiration)
>>>nonceStringYesA 32-byte hex random nonce to prevent replay attacks
paymentRequirementsObjectYesInformation describing what resource the payment grants access to (amount, network, asset, payee, etc.)
>schemeStringYesDefines how the payment is settled, e.g. exact (one‑time fixed‑amount payment)
>resourceStringNoServer URL of the resource
>descriptionStringNoDescription of the resource API endpoint
>mimeTypeStringNoMIME type of the resource provider’s response
>maxAmountRequiredStringYesMaximum payable amount in the smallest on-chain unit (e.g. for USDT with 6 decimals, 1 USDT = 1000000)
>maxTimeoutSecondsIntegerNoMaximum waiting time (in seconds) after authorization becomes valid
>payToStringYesPayee address
>assetStringNoAsset identifier or contract address (depending on the network)
>outputSchemaObjectNoOptional parameter specifying the expected JSON structure of the returned resource data
>extraObjectNoOptional additional parameters, e.g. gasLimit

Response parameters#

ParameterTypeDescription
isValidBooleanWhether the payment is valid (true = valid, false = invalid)
payerStringAddress of the payer
invalidReasonStringReason for invalidation (e.g. insufficient_funds, invalid_network, etc.)

Request example#

Shell
curl --request POST \
  --url https://web3.okx.com/api/v6/x402/verify \
  --header 'Content-Type: application/json' \
  --header 'OK-ACCESS-KEY: <your-api-key>' \
  --header 'OK-ACCESS-SIGN: <your-signature>' \
  --header 'OK-ACCESS-PASSPHRASE: <your-passphrase>' \
  --header 'OK-ACCESS-TIMESTAMP: <your-timestamp>' \
  --data '{
  "x402Version": 1,
  "chainIndex": 196,
  "paymentPayload": {
    "x402Version": 1,
    "scheme": "exact",
    "payload": {
      "signature": "<your-signature>",
      "authorization": {
        "from": "<payer-wallet-address>",
        "to": "<payee-wallet-address>",
        "value": "1000000",
        "validAfter": "<unix-timestamp-seconds>",
        "validBefore": "<unix-timestamp-seconds>",
        "nonce": "<your-nonce>"
      }
    }
  },
  "paymentRequirements": {
    "scheme": "exact",
    "maxAmountRequired": "0",
    "resource": "https://api.example.com/premium/resource/123",
    "description": "Premium API access for data analysis",
    "mimeType": "application/json",
    "outputSchema": {
      "data": "string"
    },
    "payTo": "<payee-wallet-address>",
    "maxTimeoutSeconds": 10,
    "asset": "<asset-contract-address>",
    "extra": {
      "gasLimit": "1000000"
    }
  }
}'

Response example#

Json
{
    "code": "0",
    "msg": "success",
    "data": [
        {
            "isValid": true,
            "invalidReason": null,
            "payer": "<payer-wallet-address>"
        }
    ]
}