Agent CLI

One CLI to give your AI agents full onchain superpowers.

npm install -g @polygonlabs/agent-cli

npm install -g @polygonlabs/agent-cli

Try with your agent
Install

Setup the Polygon Agent CLI for me

Fetch https://agentconnect.polygon.technology/SKILL.md and set up the Polygon Agent CLI for me

Try with your agent
Install

Optimize yield with my agent on a schedule

Read https://agentconnect.polygon.technology/SKILL.md and Deposit USDC into the highest-TVL lending vault on Polygon and report the APY and pool address. Then set up a daily cron job to automatically re-evaluate and deposit into the best vault each morning.

Try with your agent
Install

Get the active markets for Bitcoin on Polymarket

Read https://agentconnect.polygon.technology/SKILL.md and Search Polymarket for the top 5 active markets about Bitcoin and show me the current YES/NO prices for each

Try with your agent
Install

Query engagement metrics for an X profile with no API key

Read https://agentconnect.polygon.technology/SKILL.md and Use x402 to read a Twitter/X profile and recent tweets. Get follower counts, recent tweets, and engagement metrics.

Try with your agent
Install

Bridge funds from Polygon to another chain

Read https://agentconnect.polygon.technology/SKILL.md and Bridge some USDC from Polygon to Base using the cheapest available route. Confirm the arrival and report the final balance on both chains.

Try with your agent
Install
#001

     Use Cases

Yield Optimization

Deploy to the highest-yield Aave or Morpho pool on Polygon in one command—your agent selects and deposits automatically.

Copied

$ polygon-agent deposit --asset USDC --amount 2000 --protocol aave --broadcast

{
  "ok": true,
  "walletName": "main",
  "walletAddress": "0x8B3a2F9e5D1C7A4E0F6B8D2C9A1E3F5B7D9C0E2A",
  "protocol": "aave",
  "poolName": "Aave v3 USDC",
  "poolApy": "8.14%",
  "poolTvl": 48291043.22,
  "depositAddress": "0x794a61358D6845594F94dc1DB02A252b5b4814aD",
  "asset": "USDC",
  "amount": "2000",
  "chainId": 137,
  "chain": "polygon",
  "txHash": "0xa3f7c2e1b9d84f605c2e37a1d0b5f8c9e4a71b2d3e5f6a7b8c9d0e1f2a3b4c5d",
  "explorerUrl": "https://polygonscan.com/tx/0xa3f7c2e1b9d84f605c2e37a1d0b5f8c9e4a71b2d3e5f6a7b8c9d0e1f2a3b4c5d",
  "note": "USDC is now earning yield in Aave v3. You will receive an interest-bearing token (aUSDC) in your wallet."
}

Read https://agentconnect.polygon.technology/SKILL.md and Deposit USDC into the highest-TVL lending vault on Polygon and report the APY and pool address. Then set up a daily cron job to automatically re-evaluate and deposit into the best vault each morning.

Prediction Market (Polymarket)

Trade on live Polymarket markets directly from your wallet—your agent autonomously places orders and tracks positions in real time.

Copied

$ polygon-agent polymarket markets --search "bitcoin"

{
  "ok": true,
  "count": 3,
  "markets": [
    {
      "id": "5f3a1b2c-4d6e-7f8a-9b0c-1d2e3f4a5b6c",
      "conditionId": "0xd4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5",
      "question": "Will Bitcoin reach $150,000 by end of 2025?",
      "yesPrice": 0.38,
      "noPrice": 0.62,
      "yesTokenId": "0x1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b",
      "noTokenId": "0x9f8e7d6c5b4a3f2e1d0c9b8a7f6e5d4c3b2a1f0e9d8c7b6a5f4e3d2c1b0a9f8e",
      "outcomes": ["Yes", "No"],
      "volume24hr": 3841200,
      "negRisk": false,
      "endDate": "2025-12-31T23:59:59Z"
    },
    {
      "id": "6a4b5c6d-7e8f-9a0b-1c2d-3e4f5a6b7c8d",
      "conditionId": "0xe5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6",
      "question": "Will Bitcoin ETF net inflows exceed $10B in Q2 2025?",
      "yesPrice": 0.61,
      "noPrice": 0.39,
      "yesTokenId": "0x2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b3c",
      "noTokenId": "0xa0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1",
      "outcomes": ["Yes", "No"],
      "volume24hr": 1720500,
      "negRisk": false,
      "endDate": "2025-06-30T20:00:00Z"
    }
  ]
}

Search Polymarket for the top 5 active markets about Bitcoin and show me the current YES/NO prices for each.

Twitter API Query via x402

Access AI and data APIs with per-call USDC payments, your agent handles funding, signing, and responses in one command.

Copied

$ polygon-agent x402-pay \
--url https://x402-api-wrapper-production.up.railway.app/api/proxy/openrouter/chat \
--wallet x402 \
--method POST \
--body '{"model":"openai/gpt-4o-mini","messages":[{"role":"user","content":"What are the top crypto trends on Twitter today?"}]'}'

{
  "ok": true,
  "status": 200,
  "walletAddress": "0x8B3a2F9e5D1C7A4E0F6B8D2C9A1E3F5B7D9C0E2A",
  "signerAddress": "0xf150FF60f5aa52A4F3DDAc28539fA1efD24859d4",
  "funded": {
    "amount": "10000",
    "asset": "0x3c499c542cEF5E3811e1192ce70d8CC7d307c7d8",
    "txHash": "0xd4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5"
  },
  "payment": {
    "settled": true,
    "transaction": "0xe5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6"
  },
  "data": {
    "id": "gen-1744718523-xK9mPqRvNbTsLwYhJfDc",
    "model": "openai/gpt-4o-mini",
    "choices": [
      {
        "message": {
          "role": "assistant",
          "content": "Top crypto trends on Twitter today:\n\n1. **Bitcoin ATH speculation** — #BTC trending as traders discuss $150K price targets after strong ETF inflows.\n2. **Ethereum L2 activity** — #Base and #Arbitrum seeing record transaction volumes.\n3. **Polygon AI agents** — #PolygonAI trending as autonomous on-chain agents gain traction.\n4. **DeFi yield farming** — Aave v3 and Morpho Blue offering 8–12% APY on stablecoins.\n5. **Prediction markets** — Polymarket volumes spiking around macro events."
        },
        "finish_reason": "stop"
      }
    ],
    "usage": {
      "prompt_tokens": 28,
      "completion_tokens": 112,
      "total_tokens": 140
    }
  }
}

Read [https://agentconnect.polygon.technology/SKILL.md](https://agentconnect.polygon.technology/SKILL.md) and Use x402 to read a Twitter/X profile and recent tweets. Get follower counts, recent tweets, and engagement metrics.

Agent ERC-8004 Register

Mint an onchain agent identity on Polygon with ERC-8004 , build verifiable reputation and trust over time.

Copied

$ polygon-agent agent register \
--name "IdentityBot" \
--agent-uri "https://identitybot.example.com/agent.json" \
--metadata "version=1.0,capabilities=defi+identity" \
--broadcast

{
  "ok": true,
  "walletName": "main",
  "walletAddress": "0x8B3a2F9e5D1C7A4E0F6B8D2C9A1E3F5B7D9C0E2A",
  "contract": "IdentityRegistry",
  "contractAddress": "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432",
  "agentName": "IdentityBot",
  "agentURI": "https://identitybot.example.com/agent.json",
  "metadataCount": 2,
  "txHash": "0xf6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6a7",
  "explorerUrl": "https://polygonscan.com/tx/0xf6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6a7",
  "message": "Agent registered! Check transaction for agentId in Registered event."
}

"Read [https://agentconnect.polygon.technology/SKILL.md](https://agentconnect.polygon.technology/SKILL.md) and register this agent on-chain with the name 'MyAgent', then check its reputation score."

AI Image Generation

Generate images on-demand with a single command , your agent pays via USDC and returns results instantly, no APIs or accounts needed.

Copied

$ polygon-agent x402-pay \
--url "https://x402-api.onrender.com/api/call/2998d205-94d9-4f7e-8f8a-201a090a5530?prompt=a+futuristic+Polygon+blockchain+city+at+night+with+neon+lights&size=512" \
--wallet main \
--method GET

{
  "ok": true,
  "status": 200,
  "walletAddress": "0x8B3a2F9e5D1C7A4E0F6B8D2C9A1E3F5B7D9C0E2A",
  "signerAddress": "0xf150FF60f5aa52A4F3DDAc28539fA1efD24859d4",
  "funded": {
    "amount": "20000",
    "asset": "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
    "txHash": "0xa7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6a7b8"
  },
  "payment": {
    "settled": true,
    "transaction": "0xb8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6a7b8c9"
  },
  "data": {
    "ok": true,
    "prompt": "a futuristic Polygon blockchain city at night with neon lights",
    "size": "512",
    "model": "gemini-2.0-flash-exp",
    "data_uri": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAYAAAD0eNT...[base64 PNG data]",
    "credits_used": 1
  }
}

"Read [https://agentconnect.polygon.technology/SKILL.md](https://agentconnect.polygon.technology/SKILL.md) and generate an image of a futuristic Polygon city at night using the x402 image API, then show me the result."

Crosschain Swaps & Bridging

Move USDC from chain A to chain B in one command , your agent finds the cheapest route, executes the bridge, and confirms balances automatically.

Copied

$ polygon-agent swap --from USDC --to USDC --to-chain base --amount 100 --broadcast

{
  "ok": true,
  "walletName": "main",
  "walletAddress": "0x8B3a2F9e5D1C7A4E0F6B8D2C9A1E3F5B7D9C0E2A",
  "fromToken": "USDC",
  "fromChain": "polygon",
  "fromChainId": 137,
  "toToken": "USDC",
  "toChain": "base",
  "toChainId": 8453,
  "crossChain": true,
  "amount": "100",
  "intentId": "intent-9k3nQpYwRsLtMxBvJhFd-1745142400",
  "depositTxHash": "0xe1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6a7b8c9d0e1f2",
  "depositExplorerUrl": "https://polygonscan.com/tx/0xe1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6a7b8c9d0e1f2",
  "executeStatus": "completed",
  "receipt": {
    "done": true,
    "output": {
      "token": "USDC",
      "amount": "99.82",
      "chain": "base"
    }
  }
}

Read [https://agentconnect.polygon.technology/SKILL.md](https://agentconnect.polygon.technology/SKILL.md) and Bridge some USDC from Polygon to Base using the cheapest available route. Confirm the arrival and report the final balance on both chains.

PRIMER

     Core
Modules

01

Embedded Wallets

Embedded Wallets

Create smart wallets with session-based keys, spending limits, and browser-approved permissions. No seed phrases.
02

Onchain Identity

Onchain Identity

Register agents on the ERC-8004 registry on Polygon. Store metadata, link wallets, and resolve agent identities onchain.
03

Cross-chain Yield Optimization

Cross-chain Yield Optimization

Schedule your agent to automatically move funds to the best yield opportunities anywhere they may be.
04

Polymarket Trading

Polymarket Trading

Full Polymarket CLOB integration. Place buy/sell orders, manage positions, and query market data programmatically.
05

X402 Payments

X402 Payments

Pay-per-request HTTP protocol. Agents automatically pay for API access with USDC when servers respond with 402.
06

Token Operations

Token Operations

Send, swap, bridge, and check balances across any chain. Fund wallets from external accounts. See integrated DeFi vault deposits.

Ready to Launch Crypto Payments?

Let's build