# XDC Taskman — agent setup

You are setting up **XDC Taskman**, which lets you pay for x402 services on the
XDC network with USDC. You get a custodial XDC wallet and **never pay gas**
(payments use EIP-3009; a relayer covers the XDC gas).

## 0. Which path? (read first)
This guide is the **CLI** path — it needs a shell + outbound network, so it works
in **Claude Code, Cursor, Codex, or a terminal**. If you are running inside
**claude.ai web**, the CLI will NOT work (the sandbox blocks network); instead add
the **MCP connector** `https://xdctaskman-x402-server.vercel.app/mcp`
(Settings → Connectors → Add custom connector). It exposes the same flow as tools:
`login_start`, `login_verify`, `wallet_address`, `wallet_balance`,
`marketplace_list`, `call`, `wallet_transfer`.

## 1. Install / invoke the CLI

```bash
npx xdc-taskman@latest --help
```

No install step is required — `npx` fetches it on demand.

## 2. Log in (email → one-time code → an XDC wallet)

```bash
npx xdc-taskman@latest login        # prompts for email, then the emailed code
npx xdc-taskman@latest wallet address
```

A custodial XDC wallet is created for the account. Show the user the address.

## 3. Fund the wallet with USDC

Ask the human to send USDC to the wallet address (on XDC mainnet). Check it:

```bash
npx xdc-taskman@latest wallet balance
```

The agent pays **USDC** per call; **gas (XDC) is sponsored** — the user never
needs native XDC.

## 4. Discover services

```bash
npx xdc-taskman@latest marketplace list
npx xdc-taskman@latest marketplace list --capability xdc.gas-price --max-price 0.01
```

A live example service: `https://xdctaskman-x402-server.vercel.app` (manifest at
`/`, MCP discovery at `POST /mcp`).

## 5. Pay & call

```bash
npx xdc-taskman@latest call "https://xdctaskman-x402-server.vercel.app/x402/echo?msg=hi"
```

`call` runs the full x402 loop: request the URL → on HTTP 402 sign a USDC
payment authorization from the wallet → resend with the `X-PAYMENT` header →
return the result. On success it prints the settlement tx and an
`https://xdcscan.com/tx/…` explorer link.

## 6. Transfer USDC (gasless)

```bash
npx xdc-taskman@latest wallet transfer 0.5 USDC 0xRecipientAddress
```

Signs an EIP-3009 transfer; a relayer submits it and pays the gas. Returns the
explorer link and whether it succeeded.

## Reference
- Commands: `login`, `whoami`, `logout`, `wallet address|balance|fund|transfer`,
  `marketplace list`, `call`.
- All output is JSON-friendly for parsing.
- Docs: https://xdctaskman-web.vercel.app/integrate
