Skip to main content

CLI — xdcai

The xdcai CLI works anywhere you have a shell and outbound network:

  • Claude Code, Cursor, Codex, a plain terminalnpx xdcai ... works directly.
  • Claude.ai / ChatGPT web — sandboxed, no outbound network → use the MCP connector there instead.

No install needed — npx fetches it on demand.

Setup (once)

npx xdcai login # email → OTP → an XDC wallet is created for you
npx xdcai wallet address # show the address to fund with USDC
npx xdcai wallet balance # check USDC + XDC balance

Login requires accepting the Terms & Conditions. In non-interactive use, pass --accept-terms only with the user's consent.

Core loop

# find the best-matching services for a task (ranked, best first)
npx xdcai marketplace list --search weather,forecast

# pay for and call one — x402 is handled automatically
npx xdcai call https://provider.example/x402/endpoint

call requests the URL, and if it returns 402, signs an EIP-3009 USDC authorization from your wallet, resends with the X-PAYMENT header, and returns the result. A relayer settles it on-chain — you never pay gas.

Commands

CommandPurpose
login [--email <e>] [--code <c>] [--accept-terms]Authenticate; create/load your XDC wallet.
whoami / logoutShow / clear the current session.
wallet address|balance|fundWallet address, balances, funding help.
marketplace list [--search a,b,c] [--capability c] [--max-price usdc] [--sort most-used] [--min-calls n]Discover services on the live catalog.
call <url> [--method GET|POST] [--data <json>]Pay for and call a service.
history [--limit n] [--page n]Your recent paid calls + transfers (with tx hashes).
history verify <txHash>Confirm a transaction settled.

Full details and the JSON output contract: Tools & commands.

Agent output contract

Every command prints exactly one JSON object on stdout — parse that. Logs and prompts go to stderr. On failure: {"error":"..."} and a non-zero exit code. Set LOG_LEVEL=error to silence info logs.

npx xdcai call https://provider.example/x402/rates
# stdout → {"ok":true,"status":200,"paid":"0.01","txHash":"0x…","explorer":"https://xdcscan.io/tx/0x…","result":{…}}

Next: Tools & commands reference →