> ## 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 Agent CLI

> Command-line toolkit for agents on Polygon: smart wallets, Trails for funding and swaps and yield, x402 micropayments, ERC-8004 identity, and Polymarket.

The Polygon Agent CLI is one binary that gives an agent everything it needs to transact on Polygon: a wallet to spend from, fiat funding through Trails, cross-chain swaps and yield through Trails, x402 micropayments, ERC-8004 identity, and Polymarket trading. Every write command is dry-run by default. The same surface works for a developer testing flows from a laptop and an agent runtime running headless in production.

Configuration lives at `~/.polygon-agent/`. Keys are encrypted at rest with AES-256-GCM. Sessions last six months.

**Who this is for:**

* Agent developers building on Polygon who want one toolkit instead of stitching together five SDKs
* Enterprise teams running agent fleets with bounded spend and audit requirements
* Anyone testing x402, Trails, or ERC-8004 flows interactively before going to production

***

## How it works

<div style={{border:"1px solid #C8CFE1",borderRadius:"12px",overflow:"hidden",marginBottom:"24px"}}>
  <div style={{background:"linear-gradient(180deg,#EAE4F5 0%,#F6F3FB 100%)",borderBottom:"1px solid #D5C4F2",padding:"10px 16px",fontSize:"11px",fontWeight:"700",color:"#670DE5",letterSpacing:"0.06em",textTransform:"uppercase"}}>Wallet topology</div>

  <div style={{borderBottom:"1px solid #EEF0F9",padding:"9px 16px",display:"flex",alignItems:"center",gap:"10px"}}>
    <span style={{color:"#929EBA",fontSize:"11px",fontWeight:"700",minWidth:"16px",textAlign:"right"}}>1</span>
    <span style={{background:"#EEF0F9",color:"#48526F",padding:"2px 8px",borderRadius:"4px",fontSize:"11px",fontWeight:"600",whiteSpace:"nowrap"}}>Operator</span>
    <span style={{color:"#670DE5",fontWeight:"700"}}>→</span>
    <span style={{background:"#EEF0F9",color:"#48526F",padding:"2px 8px",borderRadius:"4px",fontSize:"11px",fontWeight:"600",whiteSpace:"nowrap"}}>CLI</span>
    <span style={{fontFamily:"'Geist Mono',ui-monospace,monospace",fontSize:"12px",color:"#141635"}}>polygon-agent setup → creates EOA (auth only)</span>
  </div>

  <div style={{borderBottom:"1px solid #EEF0F9",padding:"9px 16px",display:"flex",alignItems:"center",gap:"10px"}}>
    <span style={{color:"#929EBA",fontSize:"11px",fontWeight:"700",minWidth:"16px",textAlign:"right"}}>2</span>
    <span style={{background:"#EEF0F9",color:"#48526F",padding:"2px 8px",borderRadius:"4px",fontSize:"11px",fontWeight:"600",whiteSpace:"nowrap"}}>Operator</span>
    <span style={{color:"#670DE5",fontWeight:"700"}}>→</span>
    <span style={{background:"#EAE4F5",color:"#670DE5",padding:"2px 8px",borderRadius:"4px",fontSize:"11px",fontWeight:"700",whiteSpace:"nowrap"}}>OMS Wallet</span>
    <span style={{fontFamily:"'Geist Mono',ui-monospace,monospace",fontSize:"12px",color:"#141635"}}>wallet create → smart wallet (the spending wallet)</span>
  </div>

  <div style={{borderBottom:"1px solid #EEF0F9",padding:"9px 16px",display:"flex",alignItems:"center",gap:"10px"}}>
    <span style={{color:"#929EBA",fontSize:"11px",fontWeight:"700",minWidth:"16px",textAlign:"right"}}>3</span>
    <span style={{background:"#EEF0F9",color:"#48526F",padding:"2px 8px",borderRadius:"4px",fontSize:"11px",fontWeight:"600",whiteSpace:"nowrap"}}>Smart wallet</span>
    <span style={{color:"#670DE5",fontWeight:"700"}}>→</span>
    <span style={{background:"#EAE4F5",color:"#670DE5",padding:"2px 8px",borderRadius:"4px",fontSize:"11px",fontWeight:"700",whiteSpace:"nowrap"}}>Trails</span>
    <span style={{fontSize:"13px",color:"#141635"}}>Funded in fiat or crypto via `polygon-agent fund`</span>
  </div>

  <div style={{borderBottom:"1px solid #EEF0F9",padding:"9px 16px",display:"flex",alignItems:"center",gap:"10px"}}>
    <span style={{color:"#929EBA",fontSize:"11px",fontWeight:"700",minWidth:"16px",textAlign:"right"}}>4</span>
    <span style={{background:"#EAE4F5",color:"#670DE5",padding:"2px 8px",borderRadius:"4px",fontSize:"11px",fontWeight:"700",whiteSpace:"nowrap"}}>Smart wallet</span>
    <span style={{fontSize:"13px",color:"#141635",marginLeft:"4px"}}>Spends: transfers, swaps, yield, x402, identity, prediction markets</span>
  </div>

  <div style={{padding:"9px 16px",display:"flex",alignItems:"center",gap:"10px"}}>
    <span style={{color:"#929EBA",fontSize:"11px",fontWeight:"700",minWidth:"16px",textAlign:"right"}}>5</span>
    <span style={{background:"#EAE4F5",color:"#670DE5",padding:"2px 8px",borderRadius:"4px",fontSize:"11px",fontWeight:"700",whiteSpace:"nowrap"}}>CLI</span>
    <span style={{fontSize:"13px",color:"#141635",marginLeft:"4px"}}>Dry-runs every write; broadcasts only with `--broadcast`</span>
  </div>
</div>

The CLI keeps two wallets per project: an EOA that authenticates with OMS (never funded), and a smart wallet that holds the operating balance and signs every transaction. Spending limits, contract allowlists, and DeFi permissions are scoped to the smart wallet at creation. The operator never funds or exposes the EOA.

***

## Install

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

The binary is `polygon-agent`. Re-running the install command updates to the latest version.

```bash theme={null}
polygon-agent setup --name "my-project"
polygon-agent wallet create
```

`setup` provisions the EOA and OMS access key, written to `~/.polygon-agent/builder.json`. `wallet create` opens a browser approval flow and pairs a smart wallet using a six-digit code.

***

## Supported chains

| Value               | Network              |
| ------------------- | -------------------- |
| `polygon` (default) | Polygon mainnet      |
| `amoy`              | Polygon Amoy testnet |
| `mainnet`           | Ethereum mainnet     |
| `arbitrum`          | Arbitrum One         |
| `optimism`          | Optimism             |
| `base`              | Base                 |

ERC-8004 agent commands (`agent register`, `agent feedback`, etc.) operate on **Polygon mainnet only**, regardless of `--chain`.

***

## Safety model

<Warning title="Dry-run is the default">
  Every write command (`send`, `send-token`, `send-native`, `swap`, `deposit`, `withdraw`, `agent register`, `agent feedback`, and the Polymarket trading commands) runs in dry-run unless you pass `--broadcast`. The one exception is `x402-pay`, which auto-pays the 402 and submits the payment as part of the request, there is no `--broadcast` flag.
</Warning>

Keep at least **0.1 USDC or 0.1 POL** in the smart wallet at all times for gas. The CLI auto-selects USDC over POL when both are available.

***

## Sections

<CardGroup cols={2}>
  <Card title="Setup and wallets" icon="key" href="/payment-services/agentic-payments/cli/setup-and-wallets">
    `setup`, `wallet create | import | list | address | remove`, spending limits, browser approval.
  </Card>

  <Card title="Balances and funding" icon="wallet" href="/payment-services/agentic-payments/cli/balances-and-funding">
    `balances` (single + multi-chain), `fund` (Trails widget URL), gas reserve rules.
  </Card>

  <Card title="Transfers" icon="paper-plane" href="/payment-services/agentic-payments/cli/transfers">
    `send`, `send-native`, `send-token` with dry-run + broadcast.
  </Card>

  <Card title="Swaps and yield" icon="arrow-right-arrow-left" href="/payment-services/agentic-payments/cli/swaps-and-yield">
    `swap` (Trails), `deposit` and `withdraw` (Aave v3, Morpho, ERC-4626).
  </Card>

  <Card title="Pay an x402 endpoint" icon="bolt" href="/payment-services/agentic-payments/cli/x402-pay">
    `x402-pay` auto-pays 402 responses; prerequisite flow.
  </Card>

  <Card title="ERC-8004 agent identity" icon="id-card" href="/payment-services/agentic-payments/cli/agent-identity">
    `agent register`, `reputation`, `feedback`, `reviews`. Mainnet only.
  </Card>

  <Card title="Polymarket" icon="chart-line" href="/payment-services/agentic-payments/cli/polymarket">
    Prediction-market trading: `markets`, `clob-buy`, `sell`, `positions`.
  </Card>

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