Skip to content

The agentswap CLI is a published Rust crate (cargo install agentswap, version 0.2.0 on crates.io). It is a client for the AgentSwap quote service and a signer for User Proxy agent orders. It is not part of either on-chain protocol — the Intent Settler and the User Proxy have their own documentation on this site.

Source and licence: agentswapco/agentswap-cli, MIT.

Terminal window
cargo install agentswap
agentswap --version

The binary name is agentswap. Run agentswap --help for the full flag list.

By default the CLI talks to https://api.agentswap.co. Override with a flag or environment variable:

Setting Flag Environment variable Default
Service URL --url AGENTSWAP_URL https://api.agentswap.co
Terminal window
# Point one invocation at a different service
agentswap --url http://localhost:8080 health
# Or for the whole shell
export AGENTSWAP_URL=http://localhost:8080
agentswap health

An override is only useful against a service you run yourself; the default is the one to use.

A quick connectivity check:

Terminal window
agentswap health

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.

Terminal window
# Use an explicit key for one command
agentswap -k "$SR_API_KEY" key-info
# Or rely on the cached file after register
agentswap key-info

register proves wallet control with a signature and stores the returned API key. It accepts --private-key inline or --key-file:

Terminal window
agentswap register --address 0xYourWallet --key-file ./signer-key.txt

Use --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 and the MCP server — see Trade.

These apply to every subcommand.

Flag Env Purpose
-j, --json Emit raw JSON instead of tables
--url AGENTSWAP_URL Quote service base URL
-k, --key SR_API_KEY API key override
--key-file AGENTSWAP_KEY_FILE Local signer key file (trade / MCP)
Flag Env Purpose
--allow-trade Opt in to signing and relay; without it, trade is forced to dry-run
--max-amount AGENTSWAP_TRADE_MAX_AMOUNT Per-trade cap on amountIn in raw token units; refuses to sign or relay above it

Both flags are global so they also bound trades invoked through agentswap mcp. Details are on Trade.

Flag Env Purpose
--gateway-url AGENTSWAP_GATEWAY_URL Gateway URL when trade --relay submits through a relay

When the service answers a request with HTTP 402 Payment Required, the CLI signs an EIP-3009 payment and retries that request. That status is the whole trigger — the CLI does not inspect why the service asked. The knobs are below; what the payment buys is the service’s business, not the CLI’s.

Flag Env Default Purpose
--x402 AGENTSWAP_X402 off Enable the x402 paid-retry flow
--prefer-x402 off Prefer x402 even when an API key is configured
--x402-key-file AGENTSWAP_X402_KEY_FILE none Key file for x402 EIP-3009 signatures
--x402-chain AGENTSWAP_X402_CHAIN 8453 Chain ID for x402 payments
--x402-max-amount AGENTSWAP_X402_MAX_AMOUNT 0 Maximum x402 payment in raw token units
--x402-asset AGENTSWAP_X402_ASSET USDC Asset symbol or address selector
Terminal window
export AGENTSWAP_X402=1
export AGENTSWAP_X402_KEY_FILE=./x402-signer.txt
agentswap quote --chain base --from USDC --to WETH --amount 1000000
  • Commands — all fourteen subcommands
  • Trade — signing User Proxy agent orders, safety rails, and MCP