X402 Integration Guide

X402 is an on-chain payment protocol based on HTTP 402 Payment Required. With Ace Data Cloud's X402 capability, callers do not need to create an API Token or prepay account balance, but instead directly complete on-chain payment with USDC in each API request.

This set of documents is organized in the actual integration order: first complete a minimal request, then integrate the SDK, and then understand networks, billing schemes, order payments, and the Facilitator. It is recommended to read from top to bottom according to the table below.

Tutorial Applicable Scenario Link
Quick Start First use a minimal request to understand the 402, accepts, and PAYMENT-SIGNATURE flow X402 Quick Start
TypeScript SDK Call Ace Data Cloud APIs in browsers, Node.js, or frontend applications TypeScript SDK Integration
Python SDK Call APIs in Python services, scripts, Agents, or data pipelines Python SDK Integration
Order Payment Use X402 to pay for Ace Data Cloud console orders Order Payment Tutorial
Networks and Payment Methods Learn about the assets, signatures, and applicable scenarios for Base and Solana Networks and Payment Methods
exact and upto Distinguish between fixed-price APIs and post-usage settlement APIs Billing Scheme Description
Pricing Learn about the relationship between X402 prices and Credits unit prices, as well as the actual prices of each service X402 Pricing
Facilitator Understand the server-side flow of verify, settle, and self-built payment collection APIs Facilitator Integration
E2E and Troubleshooting Check public endpoints, run advanced validation tools, and locate common 402, signature, and settlement issues E2E Validation and Troubleshooting

If you only want to call Ace Data Cloud APIs, prioritize using the official SDKs:

  • TypeScript: @acedatacloud/sdk + @acedatacloud/x402-client
  • Python: acedatacloud + acedatacloud-x402

Public source code and package addresses:

Project Address
Ace Data Cloud SDK https://github.com/AceDataCloud/SDK
X402 Client https://github.com/AceDataCloud/X402Client
X402 Facilitator https://github.com/AceDataCloud/FacilitatorX402
npm SDK https://www.npmjs.com/package/@acedatacloud/sdk
npm X402 Client https://www.npmjs.com/package/@acedatacloud/x402-client
PyPI SDK https://pypi.org/project/acedatacloud/
PyPI X402 Client https://pypi.org/project/acedatacloud-x402/

The SDK automatically completes the steps of making the first unauthenticated request, parsing 402 Payment Required, calling the payment handler, and retrying with PAYMENT-SIGNATURE. You only need to prepare a wallet with USDC and choose the network you want to use.

If you want your own API to also support receiving X402 payments, you need to read the Facilitator documentation to understand the relationship between paymentRequirements, paymentPayload, /verify, and /settle.

Support Status

Ace Data Cloud X402 has completed validation on public APIs, official SDKs, Facilitator, and on-chain settlement paths. The table below summarizes the current status according to the capability dimensions most commonly used by developers during integration.

Capability Status Description
Facilitator capabilities Available https://facilitator.acedata.cloud/.well-known/x402 returns payment networks and protocol endpoints.
API 402 accepts Available Unpaid requests return available payment requirements for Base and Solana.
TypeScript SDK Available @acedatacloud/sdk and @acedatacloud/x402-client can automatically handle 402, signatures, and retries.
Python SDK Available acedatacloud and acedatacloud-x402 can automatically handle 402, signatures, and retries.
Base exact Validated on-chain Suitable for fixed-amount APIs and order payments.
Base upto Validated on-chain Suitable for post-metered APIs such as chat completions, and is currently the only network providing upto.
Solana exact HTTP paid retry validated API paid retries and model responses have been validated; it is recommended to use your own Solana RPC for on-chain signature confirmation and reconciliation.
Order Payment Validated on-chain Base exact order payment has completed on-chain settlement and updated the order status.

The following output is only used to illustrate the response format of validated paths. During actual integration, always rely on the accepts returned by the current API.

packages
@acedatacloud/sdk@2026.504.2 import ok
@acedatacloud/x402-client@2026.531.3 import ok
acedatacloud==2026.4.26.1 import ok
acedatacloud-x402==2026.5.31.3 import ok

API 402
status 402
accepts eip155:8453/exact, eip155:8453/upto, solana:5eykt4.../exact

TypeScript SDK
content ADC_TS_SDK_X402_OK

Python SDK
content ADC_PY_SDK_X402_OK

Base exact
content ADC_BASE_E2E_OK
tx 0x408430ab3451bc22a51e510cdb4b063d6b9686724fea7a31fc109af20f5cd2f3
explorer https://basescan.org/tx/0x408430ab3451bc22a51e510cdb4b063d6b9686724fea7a31fc109af20f5cd2f3

Base upto
content ADC_BASE_UPTO_OK
tx 0x4b0b836ce1cd1171cdbc37df1637150b024214ec28e7f6f2d09122f15cbfc036
explorer https://basescan.org/tx/0x4b0b836ce1cd1171cdbc37df1637150b024214ec28e7f6f2d09122f15cbfc036
signed ceiling 95215 atomic USDC
transfer value 3 atomic USDC

Solana exact
HTTP 402 -> HTTP 200
content ADC_SOLANA_E2E_OK
chain signature not confirmed in this run

Order payment
order 78481793-304e-47f7-bc0c-8231aec9cc1e state Finished pay_way X402
tx 0xfec08cc00a159ea1ec692b32faa9bf3d17595a986301169e689d94f58bc44151
explorer https://basescan.org/tx/0xfec08cc00a159ea1ec692b32faa9bf3d17595a986301169e689d94f58bc44151

Notes:

  • Both npm and PyPI packages have been installed and imported successfully in clean environments.
  • Unpaid API requests return 402, and accepts includes available payment methods for Base and Solana.
  • accepts[].network is a CAIP-2 identifier; clients must match by the CAIP-2 string when selecting a network.
  • Both the TypeScript SDK and Python SDK can automatically handle 402 and complete a paid retry.
  • Base exact, Base upto, and order payments all have publicly accessible explorer URLs.
  • The signed ceiling for Base upto is 95215 atomic USDC, while the actual settlement is 3 atomic USDC, demonstrating the characteristic of postpaid metering settlement based on actual usage.
  • Solana exact has verified HTTP 402 -> HTTP 200 and model output. Since public RPC queries may be rate-limited, it is recommended to use your own Solana RPC or platform-side settlement records to confirm the transaction signature during strict reconciliation.

Integration Notes

When developers integrate, please prioritize the real-time payment requirements returned by the current request, rather than copying example amounts or addresses from the documentation:

  • accepts[].maxAmountRequired is the maximum amount that can be signed for the current request.
  • accepts[].asset is the USDC contract or mint to use for this request.
  • accepts[].extra.chainId, accepts[].extra.facilitatorAddress, and accepts[].extra.verifyingContract participate in the EVM typed data signature.
  • upto requires the wallet to first authorize Permit2 for USDC on the target chain; if not authorized, it returns PERMIT2_ALLOWANCE_REQUIRED.
  • If you explicitly want to use postpaid metering, pass preferScheme: 'upto' in the TypeScript SDK; otherwise, the SDK selects the first available requirement returned by the server for that network.

Scope That Can Be Publicly Verified

Before integration, you can first verify these public endpoints and SDK behaviors:

  • API requests without Authorization or PAYMENT-SIGNATURE return 402 Payment Required; the accepts in the response is the sole signing basis for the current request.
  • Both the TypeScript SDK and Python SDK provide payment handlers; upon receiving 402, the SDK transport layer calls the handler and retries once.
  • https://facilitator.acedata.cloud/.well-known/x402: returns the networks, schemes, and protocol endpoints supported by the Facilitator; API prices are still subject to the real-time 402 returned by the target request.
  • https://facilitator.acedata.cloud/supported: returns the networks and schemes supported by the Facilitator.
  • The X402Client repository includes advanced on-chain verification tools that can be used to confirm signature, retry, and settlement behavior; tool output does not replace the accepts returned by the online API.

upto is a postpaid metering settlement method, suitable for APIs where actual usage is only known after the response, such as chat completions and model calls. Currently, only Base provides upto; if signature verification fails, check whether the chain id, facilitator address, spender, USDC contract, and Permit2 allowance are consistent with the 402 response.