Skip to main content
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

Wallet topology
1OperatorCLIpolygon-agent setup → creates EOA (auth only)
2OperatorOMS Walletwallet create → smart wallet (the spending wallet)
3Smart walletTrailsFunded in fiat or crypto via polygon-agent fund
4Smart walletSpends: transfers, swaps, yield, x402, identity, prediction markets
5CLIDry-runs every write; broadcasts only with --broadcast
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

npm install -g @polygonlabs/agent-cli
The binary is polygon-agent. Re-running the install command updates to the latest version.
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

ValueNetwork
polygon (default)Polygon mainnet
amoyPolygon Amoy testnet
mainnetEthereum mainnet
arbitrumArbitrum One
optimismOptimism
baseBase
ERC-8004 agent commands (agent register, agent feedback, etc.) operate on Polygon mainnet only, regardless of --chain.

Safety model

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.
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

Setup and wallets

setup, wallet create | import | list | address | remove, spending limits, browser approval.

Balances and funding

balances (single + multi-chain), fund (Trails widget URL), gas reserve rules.

Transfers

send, send-native, send-token with dry-run + broadcast.

Swaps and yield

swap (Trails), deposit and withdraw (Aave v3, Morpho, ERC-4626).

Pay an x402 endpoint

x402-pay auto-pays 402 responses; prerequisite flow.

ERC-8004 agent identity

agent register, reputation, feedback, reviews. Mainnet only.

Polymarket

Prediction-market trading: markets, clob-buy, sell, positions.

View on GitHub

Source, releases, and contribution guide.