API list

Submit transaction#

Settle the submitted transaction on the blockchain.

Request address#

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

Request parameters#

  • Request body
ParameterTypeRequiredDescription
x402VersionStringYesVersion of the x402 protocol (e.g. 1)
chainIndexStringYesUnique identifier of the blockchain
paymentPayloadObjectYesThe x402 payment payload carried by the client with the protected request
>x402VersionStringYesVersion of the x402 protocol (e.g. 1)
>schemeStringYesSettlement scheme defining how the payment is processed, 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 smallest unit, with precision)
>>>validAfterStringNoEffective time (Unix timestamp)
>>>validBeforeStringNoExpiration time (Unix timestamp)
>>>nonceStringYesRandom nonce to prevent replay attacks
paymentRequirementsObjectYesInformation describing what resource the payment grants access to (including amount, network, asset, and payee)
>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 smallest unit, with precision)
>maxTimeoutSecondsIntegerNoMaximum waiting time in seconds after the authorization becomes valid
>payToStringYesPayee address
>assetStringNoAsset identifier or contract address (depending on the network)
>outputSchemaObjectNoExpected JSON structure of the returned resource data
>extraObjectNoAdditional parameters, e.g. gasLimit

Response parameter#

ParameterTypeDescription
chainIndexStringUnique identifier of the blockchain, e.g. 196: X Layer
chainNameStringName of the blockchain, e.g. X Layer
successBooleanIndicates whether the settlement was successful
payerStringAddress of the payer
txHashStringTransaction hash of the settlement (EVM: 0x hash; Solana: Base58)
errorMsgStringError message, e.g. insufficient_funds, invalid_payload, etc

Request example#

curl --location --request POST 'https://web3.okx.com/api/v6/wallet/settle' \
--header 'Content-Type: application/json' \
--header 'OK-ACCESS-KEY: 37c541a1-****-****-****-10fe7a038418' \
--header 'OK-ACCESS-SIGN: leaV********3uw=' \
--header 'OK-ACCESS-PASSPHRASE: 1****6' \
--header 'OK-ACCESS-TIMESTAMP: 2023-10-18T12:21:41.274Z' \
  --data '{
  "x402Version": 1,
  "paymentPayload": {
    "x402Version": 1,
    "scheme": "exact",
    "chainIndex": "196",,
    "payload": {
      "signature": "0xf3746613c2d920b5fdabc0856f2aeb2d4f88ee6037b8cc5d04a71a4462f13480",
      "authorization": {
        "from": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
        "to": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
        "value": "1000000000000000000",
        "validAfter": "1716150000",
        "validBefore": "1716150000",
        "nonce": "0x1234567890abcdef1234567890abcdef12345678"
      }
    }
  },
  "paymentRequirements": {
    "scheme": "exact",
    "chainIndex": "196",,
    "maxAmountRequired": "1000000",
    "resource": "https://api.example.com/premium/resource/123",
    "description": "Premium API access for data analysis",
    "mimeType": "application/json",
    "outputSchema": {
      "data": "string"
    },
    "payTo": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
    "maxTimeoutSeconds": 10,
    "asset": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
    "extra": {
      "gasLimit": "1000000"
    }
  }
}'

Response example#

200
{
    "code": "0",
    "msg": "success",
    "data": [
        {
            "success": true,
            "errorReason": null,
            "payer": "0xcb30ed083ad246b126a3aa1f414b44346e83e67d",
            "txHash": "0x4f46ed8eac92ddbccfb56a88ff827db3616c7beb191adabbeeded901340bd7d5",
            "chainIndex": "196",
            "chainName": "X Layer"
        }
    ]
}