Verify Transaction#
Verify the validity of a transaction.
Request URL#
POST https://web3.okx.com/api/v6/x402/verify
Request Parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
| x402Version | String | Yes | x402 protocol version; pass integer 1 for v1 |
| chainIndex | String | Yes | Unique network identifier |
| paymentPayload | Object | Yes | x402 payment payload carried by the client with the protected request |
| >x402Version | String | Yes | x402 protocol version; pass integer 1 for v1 |
| >scheme | String | Yes | Settlement scheme, e.g. exact (one-time fixed-amount payment) |
| >payload | Object | Yes | Payment signature and authorization data object |
| >>signature | String | Yes | Cryptographic signature |
| >>authorization | Object | Yes | Authorization information |
| >>>from | String | Yes | Payer address |
| >>>to | String | Yes | Recipient address |
| >>>value | String | Yes | Amount in the smallest on-chain unit (e.g. USDT has 6 decimals, so 1 USDT = 1000000) |
| >>>validAfter | String | Yes | Unix timestamp (in seconds) when authorization becomes valid |
| >>>validBefore | String | Yes | Unix timestamp (in seconds) when authorization expires |
| >>>nonce | String | Yes | 32-byte hex random value to prevent replay attacks |
| paymentRequirements | Object | Yes | Payment requirements for accessing a paid resource (amount/network/asset/recipient etc.) |
| >scheme | String | Yes | Settlement scheme, e.g. exact |
| >resource | String | No | Server URL of the resource |
| >description | String | No | API description of the resource |
| >mimeType | String | No | MIME type of the resource response |
| >maxAmountRequired | String | Yes | Maximum payment amount in the smallest on-chain unit (e.g. USDT has 6 decimals, so 1 USDT = 1000000) |
| >maxTimeoutSeconds | Integer | No | Maximum wait time in seconds after authorization |
| >payTo | String | Yes | Recipient address |
| >asset | String | No | Asset identifier/contract address (network-dependent) |
| >outputSchema | Object | No | Expected JSON schema of the resource response |
| >extra | Object | No | Additional parameters, e.g. gasLimit |
Response Parameters#
| Parameter | Type | Description |
|---|---|---|
| isValid | Boolean | true means valid, false means invalid |
| payer | String | User's payment address |
| invalidReason | String | Reason 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>"
}
]
}