ChainX Protocol Documentation
Quickstart
JavaScript
// Make request to protected endpoint
const response = await fetch('https://chainx402.xyz/api/data');
// Check for HTTP 402
if (response.status === 402) {
// Extract payment info from headers
const paymentId = response.headers.get('X-Payment-Id');
const amount = response.headers.get('X-Payment-Amount');
const token = response.headers.get('X-Payment-Token');
const sellerWallet = response.headers.get('X-Payment-To');
const facilitatorUrl = response.headers.get('X-Payment-Facilitator');
// Create Solana payment transaction
// Retry with payment proof headers
const retryResponse = await fetch('https://chainx402.xyz/api/data', {
headers: {
'X-Payment-Id': paymentId,
'X-Payment-Signature': transactionSignature
}
});
}
Python
import requests
response = requests.get('https://chainx402.xyz/api/data')
if response.status_code == 402:
# Extract payment info from headers
payment_id = response.headers.get('X-Payment-Id')
amount = response.headers.get('X-Payment-Amount')
token = response.headers.get('X-Payment-Token')
seller_wallet = response.headers.get('X-Payment-To')
# Create Solana payment transaction
# Retry with payment proof
retry_response = requests.get('https://chainx402.xyz/api/data', headers={
'X-Payment-Id': payment_id,
'X-Payment-Signature': transaction_signature
})
Authentication & Payment
All requests are paid via the ChainX Protocol with automatic processing on Base or Solana. Price: $0.0004/request.
Errors
- 400 – Bad Request
- 429 – Rate Limit Exceeded (retryAfter)
- 500 – Internal Server Error