Install
The agentswap CLI is a client for the AgentSwap quote service, User Proxy agent orders, and open intents. It is not part of either on-chain protocol — the Intent Settler and the User Proxy have their own documentation on this site.
The CLI includes intent place, intent list, intent status, policy, on-chain
--self-submit, portfolio, grant-link, batch-sell, the MCP server, and x402
support.
Source and licence: agentswapco/agentswap-cli, MIT.
Install
Section titled “Install”A prebuilt binary is available for Linux and macOS:
curl -fsSL https://agentswap.co/install.sh | shagentswap --versionThe script downloads agentswap-v<version>-<target>.tar.gz and SHA256SUMS from the
GitHub Release of the version tag,
verifies the checksum, and installs the agentswap binary into $HOME/.local/bin without
sudo.
| Setting | Environment variable | Default |
|---|---|---|
| Version | AGENTSWAP_VERSION |
latest |
| Install directory | AGENTSWAP_INSTALL_DIR |
$HOME/.local/bin |
Supported platforms:
| OS | Architectures |
|---|---|
| Linux | x86_64, aarch64 |
| macOS | x86_64, arm64 |
On any other platform, the script prints the fallback method: cargo install agentswap.
# Pin a version instead of following latestcurl -fsSL https://agentswap.co/install.sh | AGENTSWAP_VERSION=0.13.0 shThe binary name is agentswap. Run agentswap --help for the full flag list.
Service endpoint
Section titled “Service endpoint”By default the CLI talks to https://api.agentswap.co. Override with a flag or
environment variable:
| Setting | Flag | Environment variable | Default |
|---|---|---|---|
| Service URL | -u, --url |
AGENTSWAP_URL |
https://api.agentswap.co |
# Point one invocation at a different serviceagentswap --url http://localhost:8080 health
# Or for the whole shellexport AGENTSWAP_URL=http://localhost:8080agentswap healthAn override is only useful against a service you run yourself; the default is the one to use.
A quick connectivity check:
agentswap healthAPI key credentials
Section titled “API key credentials”Authenticated commands need an API key. Supply it on each invocation, or register once and let the CLI cache it.
| Setting | Flag | Environment variable | Default |
|---|---|---|---|
| API key | -k, --key |
SR_API_KEY |
cached key (see below) |
| Raw JSON output | -j, --json |
— | off (formatted tables) |
Cached key. After register succeeds, the CLI writes the key to
$HOME/.agentswap/credentials (mode 0600 on Unix). Later commands read that
file automatically. Whitespace is trimmed; an empty file is ignored. If HOME is
unset, there is no credentials path and you must pass -k or SR_API_KEY every
time.
# Use an explicit key for one commandagentswap -k "$SR_API_KEY" key-info
# Or rely on the cached file after registeragentswap key-infoRegister and the private key
Section titled “Register and the private key”register proves wallet control with a signature and stores the returned API
key. It accepts --private-key inline or --key-file:
agentswap register --address 0xYourWallet --key-file ./signer-key.txtUse --key-file. A private key passed on the command line is recorded in
shell history and visible in process listings (ps). A file with restrictive
permissions avoids both.
--key-file is also available as a global flag (AGENTSWAP_KEY_FILE) for
trade, batch-sell run, intent place, and the MCP signing tools — see Trade
and Agent intents.
Global flags
Section titled “Global flags”These apply to every subcommand.
Output and service
Section titled “Output and service”| Flag | Env | Purpose |
|---|---|---|
-j, --json |
— | Emit raw JSON instead of tables |
-u, --url |
AGENTSWAP_URL |
Service base URL for quotes, tokens, pools, pricing, quota, and health |
-k, --key |
SR_API_KEY |
API key override |
--key-file |
AGENTSWAP_KEY_FILE |
Local signer key file for trade, batch-sell run, intent place, and the MCP signing tools; the x402 signer when --x402-key-file is unset |
Trade and intent safety rails
Section titled “Trade and intent safety rails”| Flag | Env | Purpose |
|---|---|---|
--allow-trade |
— | Opt in to signing and live execution; without it, trade, batch-sell run, and intent place return unsigned dry-run previews |
--max-amount |
AGENTSWAP_TRADE_MAX_AMOUNT |
Cap on amountIn in raw token units for trade, intent place, and batch-sell run; refuses to sign or submit above it |
Both flags are global so they also bound operations invoked through agentswap mcp.
Details are on Trade and Agent intents.
Intent relay
Section titled “Intent relay”intent place --relay submits to the fixed intent relay base URL https://app.agentswap.co.
The CLI has no flag or environment variable to override this URL.
RPC endpoints and lookback
Section titled “RPC endpoints and lookback”trade, intent place, intent list, intent status, policy, portfolio,
grant-link, and batch-sell read from EVM JSON-RPC endpoints, dry runs included;
--self-submit also broadcasts through them. trade, the intent commands, policy,
and a quote that names a token address outside the built-in registry first read the
endpoint’s chain id and refuse an RPC that answers a different chain than --chainid.
| Setting | Environment variable | Purpose |
|---|---|---|
| Chain RPC override | AGENTSWAP_RPC_URL_<chainId> |
Per-chain RPC URL (e.g. AGENTSWAP_RPC_URL_8453, AGENTSWAP_RPC_URL_56) |
| Global RPC override | AGENTSWAP_RPC_URL |
Fallback RPC URL for all chains |
The CLI provides built-in public endpoints for the V6 chains:
| Chain | Chain ID | Built-in public RPC | Default lookback |
|---|---|---|---|
| Base | 8453 |
https://mainnet.base.org |
200,000 blocks |
| Arbitrum One | 42161 |
https://arb1.arbitrum.io/rpc |
200,000 blocks |
| BNB Smart Chain (BSC) | 56 |
https://bsc-rpc.publicnode.com |
9,000 blocks (see below) |
| Robinhood Chain | 4663 |
https://rpc.mainnet.chain.robinhood.com |
200,000 blocks |
| Arc | 5042 |
https://rpc.mainnet.arc.io |
200,000 blocks |
BSC lookback limit. BSC’s public RPC restricts log query depth. With the built-in
RPC, the CLI defaults to 9,000 blocks on BSC. Point AGENTSWAP_RPC_URL_56 or
AGENTSWAP_RPC_URL at a keyed RPC endpoint to enable the full 200,000-block lookback,
or pass --lookback-blocks <U64> on individual queries.
# Set a keyed endpoint for BSC lookbackexport AGENTSWAP_RPC_URL_56=https://bsc-mainnet.nodereal.io/YOUR_KEYagentswap intent list --chainid 56 --owner 0xYourOwnerx402 paid retry
Section titled “x402 paid retry”Quotes, trades and intents are served without any payment. The service answers
HTTP 402 Payment Required only once a caller is past the free allowance, and
that status is the whole trigger: the CLI then signs an EIP-3009 payment and
retries that one request. It is off unless --x402 is set, and it pays nothing
unless --x402-max-amount is at or above the amount the service asks for.
| Flag | Env | Default | Purpose |
|---|---|---|---|
--x402 |
AGENTSWAP_X402 |
off | Pay and retry a request the service answered with 402 |
--prefer-x402 |
— | off | Pay a 402 even when an API key is configured; requires --x402 |
--x402-key-file |
AGENTSWAP_X402_KEY_FILE |
--key-file |
Key file for x402 EIP-3009 signatures |
--x402-chainid |
AGENTSWAP_X402_CHAINID |
8453 |
Chain ID for x402 payments |
--x402-max-amount |
AGENTSWAP_X402_MAX_AMOUNT |
0 |
Maximum x402 payment in raw token units; 0 refuses every payment |
--x402-asset |
AGENTSWAP_X402_ASSET |
USDC |
Payment asset; only USDC is supported, and any other symbol or address is refused before signing |
export AGENTSWAP_X402=1export AGENTSWAP_X402_KEY_FILE=./x402-signer.txtexport AGENTSWAP_X402_MAX_AMOUNT=10000 # raw USDC unitsagentswap quote --chainid 8453 --from USDC --to WETH --amount 1000000Next steps
Section titled “Next steps”- Commands — subcommands reference and examples
- Agent intents — open intents, listing, status, and policy
- Trade — signing User Proxy agent orders, safety rails, and MCP