npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@polygonlabs/agent-cli

v0.14.0

Published

CLI + Agent Skills for building on-chain agents on Polygon

Readme

Polygon Agent CLI


Table of Contents


Overview

Polygon Agent CLI gives AI agents everything they need to operate onchain:

  • Create and manage wallets browser-login embedded smart wallets, no private keys to manage and no keys exposed to your agent's context.
  • Send tokens, swap, bridge or any action pay in any token for any onchain action. Built-in swapping, bridging, deposits, DeFi primitives, and more.
  • Register agent identity and build reputation via ERC-8004
  • Integrated APIs query cross-chain balances, transaction history and or query nodes via dedicated RPCs
  • Payments first native gas abstraction built-in, pay end to end in stablecoins for interactions.

Quickstart

Recommended: Install on your agent

Install the Polygon Agent CLI as a skill your agent can use — works with Claude Code, Codex, Openclaw, and any agent harness that supports the skills protocol:

npx skills add https://github.com/0xPolygon/polygon-agent-cli

Once installed, your agent has access to wallet management, token operations, DEX swaps, and on-chain identity, all through the agent CLI. The long-form polygon-agent command name remains available as an alias, so both work.

Manual Install

npm (global):

npm install -g @polygonlabs/agent-cli

From source — for contributors or local development. Use pnpm polygon-agent instead of agent for all commands.

git clone https://github.com/0xPolygon/polygon-agent-cli.git
cd polygon-agent-cli
pnpm install
pnpm polygon-agent --help

After install: get your agent running

Once installed via skills or npm, run the following. If running from source, run agent commands via pnpm polygon-agent from the root of the repository (e.g., pnpm polygon-agent setup --name "MyAgent").

# 1. Log in to your embedded wallet in the browser
agent wallet login
# Prints a login page URL and opens it in a browser. Choose Google or email
# on the page; once you finish, the embedded wallet is created or unlocked.
# This works whether the browser is on this machine or elsewhere, so there
# is no separate remote mode to enable. Use --local for the older loopback
# flow, which needs the browser on this same machine.
#
# No setup step needed: the CLI ships a default OMS Builder publishable key,
# and login automatically provisions your own Builder project + access key
# (saved to ~/.polygon-agent/builder.json) for indexer and Trails quota.

# 2. Fund the wallet
agent fund

# 3. Start operating
agent balances
agent send --to 0x... --amount 1.0
agent swap --from USDC --to USDT --amount 5

# 4. Register your agent on-chain
agent register --name "MyAgent" --broadcast

Write commands preview by default — omit --broadcast to dry-run, or run agent mode auto once to always broadcast (--dry-run still previews any single command). See SKILL.md for the full agent-consumable reference.


Core Components

The CLI is built on three pillars to enable end to end onchain payments with your agents.

OMS: Wallet Infrastructure

OMS (Open Money Stack) powers all wallet operations, RPC access, and indexing.

| Capability | What it does | CLI command | | ----------- | ------------------------------------------------------------------------------------------- | ------------------------------- | | Wallets | browser-login embedded smart wallets (Account Abstraction), chain-agnostic address | wallet login, wallet list | | RPCs | Load balanced RPCs cross-chain for onchain interactions and node queries | Used internally by all commands | | Indexer | Token balance queries and transaction history across ERC-20/721/1155 | balances |

Wallets are created and unlocked via browser login (Google or email). The embedded wallet can call any contract and spend any amount it holds; there is no contract whitelist or per-token spend limit. The wallet address is the same across every supported chain, and sessions last about a week before you re-run wallet login.

Swap, Bridge & Deposit

Trails handles swapping, bridging, and onchain interactions enabling you to call any smart contract function and pay with any token. Trails handles it under the hood in a single transaction for your agent.

| Capability | What it does | CLI command | | ------------ | -------------------------------------------------------------------------------------------- | ------------------------------- | | Bridging | Move assets cross-chain into your Polygon wallet and fund the initial flows to your wallet | fund | | Swapping | Token swaps with configurable slippage seamlessly built in | swap | | Actions | Composable onchain operations (deposit / withdraw from yield, send tokens) | send, deposit, withdraw, send-token |

Onchain Agentic Identity

Native contracts for agent identity, reputation, and emerging payment standards.

| Capability | What it does | CLI command | | --------------- | -------------------------------------------------------------------------------- | ------------------------------------------------------ | | ERC-8004 | Register agents as ERC-721 NFTs with metadata and on-chain reputation | agent register, agent reputation, agent feedback | | x402 | HTTP-native micropayment protocol for agentic payments to your favorite services | x402-pay | | Native Apps | Direct interaction with any smart contract | call |

ERC-8004 contracts on Polygon:

  • Identity Registry: 0x8004A169FB4a3325136EB29fA0ceB6D2e539a432
  • Reputation Registry: 0x8004BAa17C55a88189AE136b182e5fdA19dE9b63

Plugins & Skills

The CLI ships with agent-friendly documentation designed to be consumed directly by AI agents.

| Distribution | How to install | | ------------------------------------------- | ----------------------------------------------------------- | | Skills (Claude Code, Codex, Openclaw, etc.) — recommended | npx skills add https://github.com/0xPolygon/polygon-agent-cli |

Once installed, the agent receives the full skill context — including wallet setup, token operations, and ERC-8004 registration, and can execute autonomously.

See SKILL.md for the full agent-consumable reference.


CLI Reference

Setup & Wallets

agent wallet login [--name <n>] [--local] [--no-fund] [--force]  # Log in from the browser (choose Google or email on the login page); auto-provisions Builder credentials
agent setup --oms-publishable-key <key>  # Advanced: point at your own OMS Builder project instead of the default
agent wallet logout [--name <n>]           # Log out of a wallet
agent wallet list                          # Show all wallets
agent wallet address [--name <n>]          # Show wallet address (same on every chain)
agent wallet remove [--name <n>]           # Remove a stored wallet
agent fund                                 # Open funding widget
agent mode [auto|dry-run]                  # Show or set the persisted transaction mode

Token Operations

agent balances                             # Balances on session default chain
agent balances --chain arbitrum            # Single chain override
agent balances --chains polygon,base,arbitrum  # Same wallet, multiple chains (JSON)
agent send --to 0x... --amount 1.0         # Send POL (dry-run)
agent send --symbol USDC --to 0x... --amount 10 --broadcast
agent swap --from USDC --to USDT --amount 5 --broadcast
agent withdraw --position <aToken-or-vault> --amount max [--chain <chain>]   # dry-run; add --broadcast
agent withdraw --position <aToken> --amount 0.5 --chain mainnet --broadcast   # partial (underlying units)
agent call --to 0x... --data 0x... [--value <amt>] [--prefer-native-fee] [--broadcast]   # arbitrary contract call

withdraw exits Aave v3 positions using your aToken address (POOL() + UNDERLYING_ASSET_ADDRESS()Pool.withdraw), or ERC-4626 vaults (e.g. Morpho) via redeem. Dry-run prints poolAddress / vault and calldata.

The embedded wallet can call any contract on any chain, so no pre-authorization is needed — just ensure the wallet holds a little POL or USDC for gas on the target chain. To transact on a chain other than Polygon, pass --chain <name> on the command itself.

call sends a raw transaction to any contract. The relayer takes its gas fee in USDC or POL, whichever the wallet can afford; for a native-only wallet, pass --prefer-native-fee.

Agent Registry (ERC-8004)

agent register --name "MyAgent" --broadcast
agent identity --agent-id <id>                       # payment wallet (+ --key for metadata)
agent reputation --agent-id <id>
agent feedback --agent-id <id> --value 4.5 --broadcast
agent reviews --agent-id <id> [--include-revoked]

Smart Defaults

| Default | Value | Override | | ------------- | ---------------------- | -------------------- | | Wallet name | main | --name <name> | | Chain | polygon | --chain <name\|id> | | Multi-chain balances | — | --chains <csv> (comma-separated, max 20; overrides --chain) | | Tx mode | dry-run (preview) | --broadcast, --dry-run, or persist with agent mode auto |


Environment Variables

No environment variables are required. The CLI ships a default OMS Builder publishable key, and wallet login automatically provisions your own Builder project and access key on first login, saving it to ~/.polygon-agent/builder.json.

Advanced overrides:

| Variable | Default | Description | | -------------------------- | ------------------------------------------- | ------------------------------------------------------------------------------- | | OMS_PUBLISHABLE_KEY | Baked-in default | Point at your own OMS Builder project instead of the default. Can also be set via setup --oms-publishable-key <key> (persists to ~/.polygon-agent/builder.json). | | TRAILS_API_KEY | — | Optional Trails API key for higher rate limits on swap / bridge / earn calls. | | POLYGON_AGENT_LOGIN_UI | https://agentconnect.polygon.technology | Base URL of the browser login page opened by wallet login. | | POLYGON_AGENT_OIDC_RELAY | https://oidc-relay.polygon.technology | Base URL of the OIDC handoff and login relay used by wallet login. |


Security

  • No keys to manage. The embedded wallet is unlocked via browser login (Google or email); there are no private keys exposed to the agent's context. Credentials are stored in ~/.polygon-agent/.
  • Sessions expire. Wallet sessions last about a week, after which you re-run wallet login.

Troubleshooting

| Issue | Fix | | ------------------------------------------- | ------------------------------------------------ | | Builder provisioning failed during login (see the stderr note) | It retries on the next wallet login; or run setup manually. Custom projects: export OMS_PUBLISHABLE_KEY | | Not logged in | Run agent wallet login | | Session expired | Run agent wallet login | | Insufficient funds / can't pay gas | Run fund; for a native-only wallet pass --prefer-native-fee on call | | Transaction failed | Omit --broadcast to dry-run first |


Development

# Install dependencies
pnpm install

# CLI (via root script)
pnpm polygon-agent --help

Project Structure

polygon-agent-cli/
├── packages/
│   └── polygon-agent-cli/  # CLI package (@polygonlabs/agent-cli)
│       ├── src/            # TypeScript source
│       │   ├── index.ts    # yargs entry point
│       │   ├── commands/   # Command modules (setup, mode, wallet, operations, agent)
│       │   ├── lib/        # Shared utils (storage, mode, ethauth, tokens)
│       │   └── types.d.ts  # Ambient declarations for untyped deps
│       └── contracts/      # ERC-8004 ABIs
├── skills/                 # Agent skills (SKILL.md per skill; served via agentconnect)
├── pnpm-workspace.yaml
└── package.json

Requirements: Node.js 22+


License

MIT