@acedatacloud/x402-client is responsible for signing the PAYMENT-SIGNATURE request header when encountering 402 Payment Required.
Source code and package links:
- SDK repository: https://github.com/AceDataCloud/SDK
- X402 Client repository: https://github.com/AceDataCloud/X402Client
- npm SDK: https://www.npmjs.com/package/@acedatacloud/sdk
- npm X402 Client: https://www.npmjs.com/package/@acedatacloud/x402-client
Install Dependencies
@solana/web3.js is required:
- Both
@acedatacloud/sdkand@acedatacloud/x402-clientcan be installed from npm and imported by Node.js. ethersis used for EVM typed data signing, and@solana/web3.jsis used for Solana transaction construction.
Base Example
In the browser, you can directly usewindow.ethereum. In Node.js, you can wrap ethers.Wallet in an EIP-1193-style provider.
Browser Wallet Example
When using MetaMask, Coinbase Wallet, or WalletConnect in a frontend application, you typically pass the EIP-1193 provider directly:Solana Example
Solana uses SPL USDCTransferChecked. The wallet adapter passed in needs to expose publicKey and signAndSendTransaction.
exact and does not support upto. If the API returns multiple accepts, the handler selects the item with network = 'solana'.
The Solana path has been verified on the same public API, where paid retry can return HTTP 200 and ADC_SOLANA_E2E_OK. Public RPC queries may be rate-limited, so this article does not include a Solana tx hash; when on-chain reconciliation is needed, please use your own Solana RPC or confirm through console records.
Choose exact or upto
The current TypeScript handler selects the first payment requirement matching the network returned by the server. Ace Data Cloud’s API usually places exact for the same network before upto, so if you explicitly want to use post-paid metering, you need to pass preferScheme: 'upto'.
Example:
upto requirement for that network, the handler automatically falls back to the first available requirement for that network, which is usually exact.
upto requires a one-time Permit2 authorization. upto is currently only available on Base, so only a one-time authorization for Base USDC is required:
upto has completed public API verification: HTTP 402 -> HTTP 200, and the post-paid settlement tx is 0x4b0b836ce1cd1171cdbc37df1637150b024214ec28e7f6f2d09122f15cbfc036. See the billing scheme documentation for the full output.
What the SDK Does
The transport of@acedatacloud/sdk executes the payment handler once when it receives a 402:
@acedatacloud/x402-client will:
- Select the payment requirement for the target network from
ctx.accepts. - Construct an EVM EIP-712 signature or Solana transfer transaction according to the network.
- Serialize the envelope as Base64.
- Return
{ headers: { 'PAYMENT-SIGNATURE': '<base64>' } }. - The SDK automatically retries with the original request body.

