@leashmarket/cli ships a leash binary for human operators. It wraps
the same LeashHost the standalone MCP exposes to AI agents, but
skips the MCP wire protocol and renders results as plain text (or
--json for piping into jq / scripts).
Install
npm install -g @leashmarket/cli
# or
pnpm add -g @leashmarket/cli
Pair with @leashmarket/mcp to expose the same identity to an AI agent.
Both binaries read the same ~/.config/leash/agent.json.
Bring your own RPC (strongly recommended)
The default RPCs (api.devnet.solana.com, api.mainnet-beta.solana.com) are public,
rate-limited, and slow. Every leash pay makes 3-5 RPC calls; on a public endpoint that’s a
4-8s settlement, sometimes a 429. With a private RPC it’s typically under one second.
Set LEASH_RPC_URL once and leash + leash-mcp both pick it up:
export LEASH_RPC_URL="https://devnet.helius-rpc.com/?api-key=YOUR_KEY"
leash doctor # confirms RPC reachability
Helius, Triton, QuickNode, Alchemy, or self-hosted — any standard
JSON-RPC endpoint works. You can also persist it in
~/.config/leash/agent.json under rpc_url so it’s the default for
every future shell.
Quickstart
leash agent create is a two-step flow on both devnet and
mainnet — the network is taken from LEASH_NETWORK (or
agent.json:network).
# 1a. Default (mainnet): generate a fresh executive keypair locally
# and capture the agent's public profile (name, services, …).
leash agent create \
--name "Plexpert" \
--description "Onchain accountant for indie operators." \
--image https://plexpert.xyz/avatar.png \
--service web=https://plexpert.xyz \
--service api=https://api.plexpert.xyz
# → prints the executive pubkey + a "send 0.01 SOL to ..." instruction.
# The metadata is persisted to ~/.config/leash/agent.json under
# pending_register.meta so the funded re-run picks it up.
# 1a-devnet. Override to devnet for testing:
LEASH_NETWORK=solana-devnet leash agent create --name "Plexpert"
# → same, but mints on Solana devnet.
# 1b. Or import an existing keypair (e.g. a `solana-keygen new` output).
leash agent create --executive 5Jz... \
--name "Plexpert" \
--service web=https://plexpert.xyz # base58 secret implies --import
# 2. Fund the executive (devnet airdrop is free; mainnet pulls from
# any wallet you control).
solana airdrop 1 <executive_pubkey> --url https://api.devnet.solana.com
# 3. Re-run — the same command resumes from the persisted keypair,
# mints + delegates + records, and lands `agent.json`.
leash agent create
# 4. Confirm identity.
leash agent show
# 4b. Create an agent-scoped API key for legacy bearer-token surfaces.
# The key is signed into existence by the executive keypair and plaintext
# is printed once.
leash api-key create --label "local worker"
leash api-key list
# 5. Look at the marketplace. Searches the Leash registry AND the Solana
# Foundation `pay-skills` catalogue (https://github.com/solana-foundation/pay-skills);
# each row is tagged [leash] or [pay.sh] in the output.
leash discover -q ocr --max-price 0.10
# leash discover -q email --source pay-skills # scope to a single catalogue
# Expand a chosen pay-skills provider into its individual paid endpoints
# (mirrors `pay skills endpoints <fqn>`). Use the (fqn: ...) hint emitted
# by `leash discover` for source=pay-skills rows.
# leash discover endpoints agentmail/email
# Smoke (from the monorepo root): pay-skills index + merged /v1/discover on :8801 and LEASH_API_URL from apps/agents/.env
# pnpm verify:discover
# pnpm verify:discover --rm-self # optional: delete the script after green
# 6. Vet a counterparty before paying.
leash reputation AGENT_MINT_PUBKEY
# 6b. Resolve or verify an identity selector before trusting it.
leash identity resolve --handle payce-demo
leash identity verify --domain agent.example
# 7. Pay something (x402 or MPP — probed automatically).
leash pay https://example.com/x/abc123
# POST + JSON body when the paid route needs it:
# leash pay https://api.example.com/premium --method POST --body '{"pair":"SOL/USD"}'
# 7b. Create a hosted payment link (needs LEASH_API_KEY + LEASH_API_URL).
# Default paywall is x402; add --protocol mpp for MPP (problem+json).
leash sell create-link --label "Coffee" --amount 0.50 --currency USDC
leash sell create-link --label "MPP tier" --amount 1 --protocol mpp
leash sell create-link \
--label "Design agent" \
--amount 1 \
--method POST \
--upstream-url https://api.example.com/design \
--expected-body '{"prompt":"string","style":"string"}'
# 8. Inspect or change the SPL spend authority. By default the agent
# is minted with unlimited USDC delegation; tighten, revoke, or
# extend to USDT / USDG (each token has an independent cap).
leash treasury limit --token USDC
leash treasury set-limit --token USDC --amount 100 # cap at $100 USDC
leash treasury set-limit --token USDC --revoke # pause autonomous spending
leash treasury set-limit --token USDC --unlimited # restore default
leash treasury set-limit --token USDG --unlimited # also accept USDG (Token-2022)
leash treasury set-limit --token USDT --amount 50 # cap at $50 USDT
# 9. Inspect activity.
leash receipts # latest receipts (newest first)
leash history --days 7 # last week + USD totals
leash daily --days 14 # per-day buckets
leash receipt c3c50cb352a2624f783ca6a51bdb7fbcd3b67f04b4a42cd431444db05504181a
# full ReceiptV1 by hash
# 10. Cash out.
leash treasury balance
leash treasury withdraw --to YOUR_WALLET_ADDRESS --amount 0.50 --token USDC
The first call always returns a funding_required block — render
the executive and required fields, fund the address, and re-run.
On mainnet the same flow applies; the only difference is you bring
your own SOL.
All commands
agent commands:
agent create [--name N] [--description T] [--image URL]
[--service name=https://endpoint] (repeatable)
[--generate | --import --executive <secret>]
two-step provisioning. Network = LEASH_NETWORK.
First run prints funding instructions; second
run mints + delegates + records. `--service`
advertises EIP-8004 endpoints other agents
and humans use to discover this agent
(e.g. --service web=https://my-agent.xyz).
Reserved name `receipts` is auto-injected.
agent show print active agent identity
agent export [--out PATH] export agent.json
agent import <PATH> install an agent.json
api key commands:
api-key create --label NAME [--network solana-devnet|solana-mainnet]
create an agent-scoped API key using
X-Leash-Sig; plaintext is printed once
api-key list [--include-disabled] [--limit N]
list this agent’s API keys (no plaintext)
api-key revoke <id> disable one of this agent’s API keys
treasury commands:
treasury balance list SOL + token balances
treasury withdraw --to W --amount N --token SOL|USDC|USDG|USDT
treasury limit [--token USDC|USDG|USDT]
show the active SPL Approve delegation
(delegate pubkey, remaining cap, balance)
treasury set-limit [--token USDC|USDG|USDT]
(--unlimited | --revoke | --amount N)
update the executive's SPL spend authority.
`--unlimited` writes u64::MAX (default),
`--revoke` zeros it (the agent stops
settling outgoing payments until you
re-approve), `--amount N` caps at N
human units (e.g. --amount 100 = $100 USDC).
marketplace + reputation:
discover [-q QUERY] [--max-price N] [--pricing-type T] [--source leash|pay-skills|all] [--limit N]
Searches the Leash marketplace + Solana Foundation pay-skills registry (merged).
discover endpoints <fqn>
Expand a pay-skills provider into its paid endpoint URLs (mirrors
`pay skills endpoints <fqn>`). Take <fqn> from the (fqn: ...) hint
emitted by `leash discover`.
reputation AGENT_MINT [--network solana-devnet|solana-mainnet]
identity:
identity resolve (--mint M | --handle H | --domain D)
resolve a public identity profile:
handle, domains, capability cards,
claims, and reputation summary.
identity verify (--mint M | --handle H | --domain D)
machine-readable preflight before
paying, trusting claims, or calling
a capability.
activity:
receipts [--limit N] [--direction outgoing|incoming|both]
paginated receipt feed for the active agent
receipt RECEIPT_HASH fetch a single ReceiptV1 by its hash (the
same hash the explorer renders at
/receipt/{hash}). Returns price legs,
decision, request URL, tx_signature, and
the prev/current hash chain.
history [--days N] [--direction outgoing|incoming|both] [--limit N]
receipts in the last N days (default 7)
plus running totals: sent / received /
net in USD. Stables (USDC/USDG/USDT)
summed at 1:1 USD.
daily [--days N] per-day P&L buckets for the last N days
(default 7). One row per UTC day with
sent_usd, received_usd, net_usd, and
per-direction counts.
pay <link-url> [--method GET|POST]
[--body <json>] probe → sign → settle via buyer-kit.
x402 + MPP are auto-detected; use POST/body
when the seller route requires it.
sell create-link --label L --amount N [--currency C]
[--description …] [--method GET|POST]
[--upstream-url URL] [--expected-body JSON]
[--protocol x402|mpp]
create a hosted payment link (LEASH_API_KEY).
--expected-body documents POST body metadata.
Default protocol x402; mpp for MPP paywalls.
misc:
doctor config + RPC + API reachability check
help, -h full help
version, -v installed version
global flags:
--json emit raw LeashToolResult payload
Verify it works
Prints config path, derived executive pubkey, network, RPC + API
reachability — first stop for any “why isn’t this working” question.
Cross-interface portability
leash agent export and leash agent import are aliases for the
matching leash-mcp subcommands — same JSON shape, same on-disk
location. An agent minted in any host can roam to any other host
by exporting the file there and importing it on the new machine.
# On machine A:
leash agent export --out /tmp/my-agent.json
scp /tmp/my-agent.json user@machine-b:/tmp/
# On machine B:
leash agent import /tmp/my-agent.json
leash agent show # same on-chain identity, same treasury, same reputation
Today the portability flow is one-way for the chat product:
- Chat → CLI / Cursor — Yes. Open the agent’s profile in the
chat product, copy its mint + executive secret into
~/.config/leash/agent.json (or use leash agent import), and
every CLI / MCP command operates on the same on-chain identity.
- CLI / Cursor → Chat — On the roadmap. The chat product’s
database currently only knows about agents minted from its own UI;
importing a CLI-minted agent requires a server-side ownership-
proof endpoint (signs a nonce with the executive key) that hasn’t
shipped yet.
Troubleshooting
| Symptom | Likely cause + fix |
|---|
leash agent create returns Step 1 of 2 — fund the executive... | Expected. Send the printed SOL amount to the printed pubkey, then run leash agent create again. |
leash agent create errors with ... not visible on RPC within 20s | RPC propagation delay between mint confirmation and account read. Re-run; the resume path picks up where it left off. |
leash agent create --import errors mode: "import" requires executive_secret_base58 | Pass --executive <base58_secret> along with --import (or use --executive alone). |
leash pay is slow (5–10s) or 429s | You’re on the public RPC. Set LEASH_RPC_URL to a paid endpoint — see Bring your own RPC above. |
| Wrong network on every command | leash-mcp and leash both honour LEASH_NETWORK. Set it explicitly to override agent.json. |
leash treasury withdraw returns error | Most common: amount > available balance, or wrong --token symbol for the network’s mint. |
leash receipts returns error: 401 | Receipts read still uses a bearer key today. Set LEASH_API_KEY in your shell. |
Source