> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xenarch.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Agent Quickstart

> AI agent payments quickstart — pay for x402-gated content with USDC micropayments in 5 minutes using the Xenarch MCP server or Python SDK.

## Prerequisites

* Python 3.10+
* A wallet with USDC on Base (+ small ETH for gas)
* For testnet: use `base-sepolia` with test USDC

## Install the SDK

```bash theme={null}
pip install xenarch[agent]
```

## Configure your wallet

The SDK loads wallet configuration from environment variables or `~/.xenarch/wallet.json`.

<Tabs>
  <Tab title="Environment variables">
    ```bash theme={null}
    export XENARCH_PRIVATE_KEY="0xYOUR_PRIVATE_KEY"
    export XENARCH_NETWORK="base"           # or base-sepolia for testnet
    export XENARCH_RPC_URL="https://mainnet.base.org"
    ```
  </Tab>

  <Tab title="Config file">
    ```bash theme={null}
    mkdir -p ~/.xenarch
    cat > ~/.xenarch/wallet.json << 'EOF'
    {
      "privateKey": "0xYOUR_PRIVATE_KEY"
    }
    EOF
    chmod 600 ~/.xenarch/wallet.json
    ```
  </Tab>

  <Tab title="Auto-generate">
    Call `load_wallet_or_create()` and the SDK generates a new wallet at `~/.xenarch/wallet.json` automatically. Fund it with USDC before making payments.
  </Tab>
</Tabs>

## Pay for gated content

```python theme={null}
from xenarch.agent_client import check_gate, verify_payment
from xenarch.payment import execute_payment
from xenarch.wallet import load_wallet_or_create

wallet = load_wallet_or_create()

# 1. Check if the URL has a payment gate
gate = check_gate("https://example.com/premium")
if not gate:
    print("No gate — content is free")
else:
    print(f"Price: ${gate.price_usd} USDC")

    # 2. Pay on-chain
    result = execute_payment(
        wallet=wallet,
        splitter_address=gate.splitter,
        collector_address=gate.collector,
        price_usd=gate.price_usd,
    )
    print(f"TX: {result.tx_hash}")

    # 3. Verify and get access token
    verification = verify_payment(gate.verify_url, result.tx_hash)
    token = verification["access_token"]

    # 4. Fetch content with token
    import httpx
    resp = httpx.get(
        "https://example.com/premium",
        headers={"Authorization": f"Bearer {token}"},
    )
    print(resp.text)
```

## Alternative: use the MCP server

If you're using Claude Desktop or Claude Code, add Xenarch as an MCP server — no code required:

```bash theme={null}
claude mcp add xenarch -- npx @xenarch/agent-mcp
```

Then ask Claude: *"Check if example.com has a paywall and pay for access."*

See [MCP installation](/mcp/installation) for full setup.

## Alternative: use LangChain or CrewAI

<Tabs>
  <Tab title="LangChain">
    ```bash theme={null}
    pip install xenarch[agent,langchain]
    ```

    ```python theme={null}
    from xenarch.tools.langchain import CheckGateTool, PayTool, GetHistoryTool
    tools = [CheckGateTool(), PayTool(), GetHistoryTool()]
    ```

    See the [LangChain integration guide](/integrations/langchain).
  </Tab>

  <Tab title="CrewAI">
    ```bash theme={null}
    pip install xenarch[agent,crewai]
    ```

    ```python theme={null}
    from xenarch.tools.crewai import check_gate, pay, get_history
    tools = [check_gate, pay, get_history]
    ```

    See the [CrewAI integration guide](/integrations/crewai).
  </Tab>
</Tabs>

## Testnet

For testing without real funds, use Base Sepolia:

```bash theme={null}
export XENARCH_NETWORK="base-sepolia"
export XENARCH_RPC_URL="https://sepolia.base.org"
```

The testnet uses a mock USDC contract (`0xc5aDdd66Da733101A5468857Aa3C6689Af9d1DDc`) where anyone can mint tokens.
