Payment API

Verify Transaction#

Verify the validity of a transaction.

Request URL#

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

Request Parameters#

ParameterTypeRequiredDescription
x402VersionStringYesx402 protocol version; pass integer 1 for v1
chainIndexStringYesUnique network identifier
paymentPayloadObjectYesx402 payment payload carried by the client with the protected request
>x402VersionStringYesx402 protocol version; pass integer 1 for v1
>schemeStringYesSettlement scheme, e.g. exact (one-time fixed-amount payment)
>payloadObjectYesPayment signature and authorization data object
>>signatureStringYesCryptographic signature
>>authorizationObjectYesAuthorization information
>>>fromStringYesPayer address
>>>toStringYesRecipient address
>>>valueStringYesAmount in the smallest on-chain unit (e.g. USDT has 6 decimals, so 1 USDT = 1000000)
>>>validAfterStringYesUnix timestamp (in seconds) when authorization becomes valid
>>>validBeforeStringYesUnix timestamp (in seconds) when authorization expires
>>>nonceStringYes32-byte hex random value to prevent replay attacks
paymentRequirementsObjectYesPayment requirements for accessing a paid resource (amount/network/asset/recipient etc.)
>schemeStringYesSettlement scheme, e.g. exact
>resourceStringNoServer URL of the resource
>descriptionStringNoAPI description of the resource
>mimeTypeStringNoMIME type of the resource response
>maxAmountRequiredStringYesMaximum payment amount in the smallest on-chain unit (e.g. USDT has 6 decimals, so 1 USDT = 1000000)
>maxTimeoutSecondsIntegerNoMaximum wait time in seconds after authorization
>payToStringYesRecipient address
>assetStringNoAsset identifier/contract address (network-dependent)
>outputSchemaObjectNoExpected JSON schema of the resource response
>extraObjectNoAdditional parameters, e.g. gasLimit

Response Parameters#

ParameterTypeDescription
isValidBooleantrue means valid, false means invalid
payerStringUser's payment address
invalidReasonStringReason for invalidity, 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>"
        }
    ]
}