Submit transaction#
Submit the signed transaction to the blockchain for on-chain settlement.
Request address#
POST https://web3.okx.com/api/v6/x402/settle
Request parameters#
- Request body
| Parameter | Type | Required | Description |
|---|---|---|---|
| x402Version | String | Yes | Version of the x402 protocol. For v1, pass integer 1 |
| chainIndex | String | Yes | Unique identifier of the blockchain |
| paymentPayload | Object | Yes | The x402 payment payload carried by the client with the protected request |
| >x402Version | String | Yes | Version of the x402 protocol. For v1, pass integer 1 |
| >scheme | String | Yes | Settlement scheme defining how the payment is processed, e.g. exact (one‑time fixed‑amount payment) |
| >payload | Object | Yes | Object containing payment signature and authorization data |
| >>signature | String | Yes | Cryptographic signature |
| >>authorization | Object | Yes | Authorization information |
| >>>from | String | Yes | Payer address |
| >>>to | String | Yes | Payee address |
| >>>value | String | Yes | Payment amount in the smallest on-chain unit (e.g. for USDT with 6 decimals, 1 USDT = 1000000) |
| >>>validAfter | String | Yes | Unix timestamp (seconds) after which the authorization becomes valid |
| >>>validBefore | String | Yes | Unix timestamp (seconds) before which the authorization is valid (expiration) |
| >>>nonce | String | Yes | A 32-byte hex random nonce to prevent replay attacks |
| paymentRequirements | Object | Yes | Information describing what resource the payment grants access to (including amount, network, asset, and payee) |
| >scheme | String | Yes | Defines how the payment is settled, e.g. exact (one‑time fixed‑amount payment) |
| >resource | String | No | Server URL of the resource |
| >description | String | No | Description of the resource API endpoint |
| >mimeType | String | No | MIME type of the resource provider’s response |
| >maxAmountRequired | String | Yes | Maximum payable amount in the smallest on-chain unit (e.g. for USDT with 6 decimals, 1 USDT = 1000000) |
| >maxTimeoutSeconds | Integer | No | Maximum waiting time in seconds after the authorization becomes valid |
| >payTo | String | Yes | Payee address |
| >asset | String | No | Asset identifier or contract address (depending on the network) |
| >outputSchema | Object | No | Expected JSON structure of the returned resource data |
| >extra | Object | No | Additional parameters, e.g. gasLimit |
Response parameter#
| Parameter | Type | Description |
|---|---|---|
| chainIndex | String | Unique identifier of the blockchain, e.g. 196: X Layer |
| chainName | String | Name of the blockchain, e.g. X Layer |
| success | Boolean | Indicates whether the settlement was successful |
| payer | String | Address of the payer |
| txHash | String | Transaction hash of the settlement (EVM: 0x hash; Solana: Base58) |
| errorMsg | String | Error message, e.g. insufficient_funds, invalid_payload, etc |
Request example#
Shell
curl --location --request POST 'https://web3.okx.com/api/v6/x402/settle' \
--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": [
{
"success": true,
"errorReason": null,
"payer": "<payer-wallet-address>",
"txHash": "<transaction-hash>",
"chainIndex": "196",
"chainName": "X Layer"
}
]
}