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

# Polygon Agentic CLI

> A single CLI toolkit for AI agents: smart contract wallets, token operations, x402 micropayments, and onchain identity.

The Polygon Agentic CLI is a command-line toolkit that gives AI agents and autonomous applications full access to the Polygon payments stack in a single install. It handles wallet creation, token transfers, cross-chain bridging, x402 micropayments, and ERC-8004 onchain identity without requiring agents to manage multiple SDKs or dependencies.

<Card title="View on GitHub" icon="github" href="https://github.com/0xPolygon/polygon-agent-cli">
  Source code, releases, and contribution guide.
</Card>

## What it includes

| Capability                 | Description                                                                                                               |
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| **Smart contract wallets** | Session-based wallets via Sequence. Create and manage wallets with scoped permissions per agent session.                  |
| **Token operations**       | Send, swap, bridge, and deposit tokens via Trails routing. Single command for any cross-chain transfer.                   |
| **x402 micropayments**     | Pay x402-protected API endpoints and register resources as a seller. Built-in buyer and seller flows.                     |
| **ERC-8004 identity**      | Register and update onchain agent identity and reputation. Interact with Identity, Reputation, and Validation registries. |
| **Encrypted storage**      | AES-256-GCM encrypted local storage for keys and session state. No plaintext secrets on disk.                             |

## Install

```bash theme={null}
npm install -g @0xpolygon/agent-cli
```

Or run directly without installing:

```bash theme={null}
npx @0xpolygon/agent-cli
```

## Quick start

**1. Create a wallet**

```bash theme={null}
polygon-agent wallet create
```

This generates a smart contract wallet secured by a session key. The private key is stored locally with AES-256-GCM encryption.

**2. Fund the wallet**

```bash theme={null}
polygon-agent wallet fund --network polygon
```

**3. Send tokens**

```bash theme={null}
polygon-agent token send \
  --to 0xRecipient \
  --amount 10 \
  --token USDC \
  --network polygon
```

**4. Pay an x402 endpoint**

```bash theme={null}
polygon-agent x402 pay --url https://api.example.com/resource
```

The CLI detects the 402 response, constructs the payment, and retries the request automatically.

**5. Register agent identity**

```bash theme={null}
polygon-agent identity register --name "my-agent" --description "Trading agent"
```

This writes an ERC-8004 identity record on Polygon mainnet.

## Key commands

### Wallet

| Command          | Description                                      |
| ---------------- | ------------------------------------------------ |
| `wallet create`  | Create a new session-based smart contract wallet |
| `wallet list`    | List all managed wallets                         |
| `wallet balance` | Show token balances for a wallet                 |
| `wallet export`  | Export wallet credentials                        |

### Token operations

| Command         | Description                    |
| --------------- | ------------------------------ |
| `token send`    | Transfer tokens to an address  |
| `token swap`    | Swap tokens via Trails routing |
| `token bridge`  | Bridge tokens cross-chain      |
| `token deposit` | Deposit tokens to a protocol   |

### x402

| Command       | Description                                       |
| ------------- | ------------------------------------------------- |
| `x402 pay`    | Pay an x402-protected endpoint                    |
| `x402 serve`  | Protect a local endpoint with x402 payment gating |
| `x402 status` | Check payment status for a resource               |

### Identity (ERC-8004)

| Command               | Description                                                   |
| --------------------- | ------------------------------------------------------------- |
| `identity register`   | Register onchain agent identity                               |
| `identity update`     | Update identity metadata                                      |
| `identity reputation` | Read reputation score for an agent address                    |
| `identity verify`     | Verify an agent's credentials against the Validation registry |

## Configuration

The CLI reads from `~/.polygon-agent/config.json` by default. You can override with `--config`:

```bash theme={null}
polygon-agent --config ./my-config.json wallet list
```

Key configuration options:

```json theme={null}
{
  "network": "polygon",
  "rpc": "https://polygon-rpc.com",
  "keystore": "~/.polygon-agent/keys",
  "x402": {
    "facilitator": "https://facilitator.polygon.technology"
  }
}
```

## Security

* Private keys are encrypted at rest with AES-256-GCM
* Session keys are scoped per operation with configurable spending limits
* No keys are transmitted to external services

## Related

<CardGroup cols={2}>
  <Card title="x402 Protocol" href="/payment-services/agentic-payments/x402/intro">
    HTTP-native micropayments that the CLI uses under the hood.
  </Card>

  <Card title="ERC-8004" href="/payment-services/agentic-payments/agent-integration/erc8004">
    Onchain identity and reputation standard for agents.
  </Card>

  <Card title="LLM Wallet MCP" href="/payment-services/agentic-payments/agent-integration/tools/llm-wallet">
    MCP server for wallet operations inside Claude and Cursor.
  </Card>

  <Card title="Agentic Wallets" href="/wallets/agentic-wallets">
    Wallet infrastructure designed for autonomous agent use.
  </Card>
</CardGroup>
