OpenclawCash Agent API
Interact with OpenclawCash-managed wallets to send native assets and tokens, check balances, execute DEX swaps, and manage Polymarket account, orders, and redeem flows via Polygon wallets.
This skill may also be referred to as openclawcash.
Requirements
- Required env var:
AGENTWALLETAPI_KEY
- Optional env var:
AGENTWALLETAPI_URL (default: https://openclawcash.com)
- Required local binary:
curl
- Optional local binary:
jq (for pretty JSON output in CLI)
- Network access required:
https://openclawcash.com
Preferred Integration Path
Safety Model
- Start with read-only calls (
wallets, wallet, balance, tokens) on testnets first.
- High-risk actions are gated:
- API key permissions in dashboard (
allowWalletCreation, allowWalletImport)
- Explicit CLI confirmation (
--yes) for write actions
- Agents should establish an approval mode early in the session for write actions:
confirm_each_write: ask before every write action.
operate_on_my_behalf: after one explicit onboarding approval, execute future write actions without re-asking, as long as the user keeps instructing the agent in the same session.
- For
operate_on_my_behalf, the agent should treat the user's later task messages as execution instructions and run the corresponding write commands with --yes.
- Ask again only if:
- the user revokes or changes approval mode
- the session is restarted or memory is lost
- the action is outside the scope the user approved
- the agent is unsure which wallet, token, amount, destination, spender, or chain is intended
- If the user gives only a broad instruction like "go ahead" but execution details are still missing, gather the missing details first instead of repeating a generic permission request.
Setup
- Run the setup script to create your
.env file:bash scripts/setup.sh
- Edit the
.env file in this skill folder and replace the placeholder with your real API key:AGENTWALLETAPI_KEY=occ_your_api_key
- Get your API key at https://openclawcash.com (sign up, create a wallet, go to API Keys page).
Legacy CLI Fallback
If MCP is unavailable, use the included tool script to make API calls directly:
# Read-only (recommended first)
bash scripts/agentwalletapi.sh wallets
bash scripts/agentwalletapi.sh user-tag-get
bash scripts/agentwalletapi.sh user-tag-set my-agent-tag --yes
bash scripts/agentwalletapi.sh wallet Q7X2K9P
bash scripts/agentwalletapi.sh wallet "Trading Bot"
bash scripts/agentwalletapi.sh balance Q7X2K9P
bash scripts/agentwalletapi.sh transactions Q7X2K9P
bash scripts/agentwalletapi.sh tokens mainnet
# Write actions (require explicit --yes)
export WALLET_EXPORT_PASSPHRASE_OPS='your-strong-passphrase'
bash scripts/agentwalletapi.sh create "Ops Wallet" sepolia WALLET_EXPORT_PASSPHRASE_OPS --yes
bash scripts/agentwalletapi.sh import "Treasury Imported" mainnet --yes
bash scripts/agentwalletapi.sh import "Poly Ops" polygon-mainnet --yes
# Automation-safe import: read private key from stdin instead of command args
printf '%s' '<private_key>' | bash scripts/agentwalletapi.sh import "Treasury Imported" mainnet - --yes
bash scripts/agentwalletapi.sh transfer Q7X2K9P 0xRecipient 0.01 --yes
bash scripts/agentwalletapi.sh transfer Q7X2K9P 0xRecipient 100 USDC --yes
bash scripts/agentwalletapi.sh quote mainnet WETH USDC 10000000000000000
bash scripts/agentwalletapi.sh quote solana-mainnet SOL USDC 10000000 solana
bash scripts/agentwalletapi.sh swap Q7X2K9P WETH USDC 10000000000000000 0.5 --yes
# Checkout escrow lifecycle
bash scripts/agentwalletapi.sh checkout-payreq-create Q7X2K9P 30000000 --yes
bash scripts/agentwalletapi.sh checkout-payreq-get pr_a1b2c3
bash scripts/agentwalletapi.sh checkout-escrow-get es_d4e5f6
bash scripts/agentwalletapi.sh checkout-quick-pay es_d4e5f6 Q7X2K9P --yes
bash scripts/agentwalletapi.sh checkout-swap-and-pay-quote es_d4e5f6 Q7X2K9P
bash scripts/agentwalletapi.sh checkout-swap-and-pay-confirm es_d4e5f6 Q7X2K9P 1 --yes
bash scripts/agentwalletapi.sh checkout-release es_d4e5f6 --yes
bash scripts/agentwalletapi.sh checkout-refund es_d4e5f6 --yes
bash scripts/agentwalletapi.sh checkout-cancel es_d4e5f6 --yes
bash scripts/agentwalletapi.sh checkout-webhooks-list
# Polymarket setup is user-managed in dashboard Venues settings
# Direct setup page: https://openclawcash.com/venues/polymarket
bash scripts/agentwalletapi.sh polymarket-market Q7X2K9P 123456 BUY 25 FAK 0.65 --yes
bash scripts/agentwalletapi.sh polymarket-resolve https://polymarket.com/market/market-slug No
bash scripts/agentwalletapi.sh polymarket-account Q7X2K9P
bash scripts/agentwalletapi.sh polymarket-orders Q7X2K9P OPEN 50
bash scripts/agentwalletapi.sh polymarket-activity Q7X2K9P 50
bash scripts/agentwalletapi.sh polymarket-positions Q7X2K9P 100
bash scripts/agentwalletapi.sh polymarket-redeem Q7X2K9P all 100 --yes
bash scripts/agentwalletapi.sh polymarket-redeem Q7X2K9P 1234567890 100 --yes
bash scripts/agentwalletapi.sh polymarket-cancel Q7X2K9P order_id_here --yes
Base-Units Rule (Important)
quote.amountIn, swap.amountIn, approve.amount, and transfer valueBaseUnits must be base-units integer strings (digits only).
- Do not send decimal strings in these fields (for example,
0.001), or validation will fail immediately.
- Examples:
0.001 ETH -> 1000000000000000 wei
1 USDC (6 decimals) -> 1000000
- For transfer, use
amountDisplay when you want human-readable units and let the API convert.
- Legacy transfer aliases
amount and value are still accepted for compatibility.
Import Input Safety
- Wallet import is optional and not required for normal wallet operations (list, balance, transfer, swap).
- Import works only when the user explicitly enables API key permission
allowWalletImport in dashboard settings.
- Import execution requires explicit confirmation in the CLI (
--yes for automation, or interactive YES prompt).
- Avoid passing sensitive inputs as CLI arguments when possible (shell history/process logs risk).
- Preferred options:
- Interactive hidden prompt: omit the private key argument.
- Automation: pass
- and pipe input via stdin.
Base URL
https://openclawcash.com
Troubleshooting
If requests fail because of host/URL issues, use this recovery flow:
- Open
agentwalletapi/.env and verify AGENTWALLETAPI_KEY is set and has no extra spaces.
- If the API host is wrong or unreachable, set this in the same
.env file:AGENTWALLETAPI_URL=https://openclawcash.com
- Retry a simple read call first:
bash scripts/agentwalletapi.sh wallets
- If it still fails, report the exact error and stop before attempting transfer/swap actions.
Authentication
The API key is loaded from the .env file in this skill folder. For direct HTTP calls, include it as a header:
X-Agent-Key: occ_your_api_key
Content-Type: application/json
API Surfaces
- Agent API (API key auth):
/api/agent/*
- Authenticate with
X-Agent-Key
- Used for autonomous agent execution (wallets list/create/import, transactions, balance, transfer, swap, quote, approve, checkout escrow lifecycle, and polymarket venue operations)
- Public docs intentionally include only
/api/agent/* endpoints.
Workflow
GET /api/agent/wallets - Discover available wallets (id, label, address, network, chain). Optional ?includeBalances=true adds native balance + nativeSymbol
GET /api/agent/wallet?walletId=... or ?walletLabel=... or ?walletAddress=... - Fetch one wallet with native/token balances
- Optional wallet lifecycle actions:
POST /api/agent/wallets/create - Create a new wallet under API-key policy controls
POST /api/agent/wallets/import - Import a mainnet, polygon-mainnet, or solana-mainnet wallet under API-key policy controls
GET /api/agent/transactions?walletId=... (or walletLabel/walletAddress) - Read merged wallet transaction history (on-chain + app-recorded)
GET /api/agent/supported-tokens?network=... or ?chain=evm|solana - Get recommended common, well-known token list + guidance (requires X-Agent-Key)
POST /api/agent/token-balance - Check wallet balances (native + token balances; specific token by symbol/address supported)
POST /api/agent/quote - Get a swap quote before execution on Uniswap (EVM) or Jupiter (Solana mainnet). amountIn is base-units integer string.
POST /api/agent/swap - Execute token swap on Uniswap (EVM) or Jupiter (Solana mainnet). amountIn is base-units integer string.
POST /api/agent/transfer - Send native coin or token on the wallet's chain (optional chain guard). Do not use this for checkout escrow funding.
GET /api/agent/user-tag and PUT /api/agent/user-tag - Read/set the global checkout user tag (set is one-time / immutable once configured)
- Optional checkout flow (escrow by global user tag):
- MCP default:
checkout_fund (tries quick-pay, falls back to swap-and-pay when needed)
POST /api/agent/checkout/payreq - Create pay request + escrow
GET /api/agent/checkout/payreq/:id - Read pay request
POST /api/agent/checkout/escrows/:id/funding-confirm - Confirm funding by tx hash
POST /api/agent/checkout/escrows/:id/quick-pay - Direct buyer funding
POST /api/agent/checkout/escrows/:id/swap-and-pay - Quote/execute swap funding
GET /api/agent/checkout/escrows/:id - Read escrow state
POST /api/agent/checkout/escrows/:id/accept - Accept as buyer
POST /api/agent/checkout/escrows/:id/proof - Submit proof
POST /api/agent/checkout/escrows/:id/dispute - Open dispute
POST /api/agent/checkout/escrows/:id/release - Release funds
POST /api/agent/checkout/escrows/:id/refund - Refund funds
POST /api/agent/checkout/escrows/:id/cancel - Cancel escrow
GET|POST /api/agent/checkout/webhooks and PATCH|DELETE /api/agent/checkout/webhooks/:id - Manage webhooks
Checkout timing fields for POST /api/agent/checkout/payreq:
expiresInSeconds: funding deadline before request expires.
autoReleaseSeconds: when funded escrow can auto-release if no dispute exists.
disputeWindowSeconds: how long dispute can be opened after auto-release point.
- Constraints: all three must be at least
3600 seconds, and disputeWindowSeconds <= autoReleaseSeconds.
- Optional Polymarket venue flow (polygon-mainnet wallets only):
- Prerequisite: user configures Polymarket in dashboard Venues settings for that wallet
GET /api/agent/venues/polymarket/market/resolve resolves marketUrl/slug + human-readable outcome to the exact tokenId needed for order tools
- MCP helper:
polymarket_market_resolve calls the same agent endpoint
POST /api/agent/venues/polymarket/orders/limit - Place BUY/SELL limit orders
POST /api/agent/venues/polymarket/orders/market - Place BUY/SELL market orders
GET /api/agent/venues/polymarket/account - Read account summary
GET /api/agent/venues/polymarket/orders - List open orders
POST /api/agent/venues/polymarket/orders/cancel - Cancel an order
POST /api/agent/venues/polymarket/redeem - Redeem one position by tokenId or redeem all redeemable positions
POST /api/agent/venues/polymarket/unlink - Clear stored Polymarket integration config for a wallet
GET /api/agent/venues/polymarket/activity - List trade activity
GET /api/agent/venues/polymarket/positions - List open positions (open-market filtered, includes PnL fields)
- Use returned
txHash / orderId values to confirm execution and lifecycle status
Approval Handling For Agents
Use this pattern for write actions:
- At the first write-intent in a session, ask one short onboarding question:
- "Do you want approval for every write action, or should I operate on your behalf for this session?"
- Store the chosen mode in conversation memory.
- If the mode is
confirm_each_write:
- ask for approval before each transfer, swap, approval, import, or wallet creation
- after approval, execute with the MCP write tool or the legacy CLI fallback with
--yes
- If the mode is
operate_on_my_behalf:
- do not ask again for each transfer
- when the user later says things like "send X to Y" or "swap A for B", execute with the MCP write tool or the legacy CLI fallback with
--yes once the needed details are clear
- In either mode:
- if execution details are missing, ask only for the missing details
- if the user changes modes or revokes permission, update memory and follow the new rule
Recommended onboarding wording:
- "Choose write approval mode for this session:
confirm_each_write or operate_on_my_behalf."
Example:
Quick Reference
| Endpoint |
Method |
Auth |
Purpose |
/api/agent/wallets |
GET |
Yes |
List wallets (discovery; optional includeBalances=true for native balances) |
/api/agent/wallet |
GET |
Yes |
Get one wallet detail with native/token balances |
/api/agent/wallets/create |
POST |
Yes |
Create a new API-key-managed wallet |
/api/agent/wallets/import |
POST |
Yes |
Import a mainnet/polygon-mainnet/solana-mainnet wallet via API key |
/api/agent/transactions |
GET |
Yes |
List per-wallet transaction history |
/api/agent/transfer |
POST |
Yes |
Send native/token transfers (EVM + Solana). Not the checkout escrow funding path. |
/api/agent/swap |
POST |
Yes |
Execute DEX swap (Uniswap on EVM, Jupiter on Solana mainnet) |
/api/agent/quote |
POST |
Yes |
Get swap quotes (Uniswap on EVM, Jupiter on Solana mainnet) |
/api/agent/token-balance |
POST |
Yes |
Check balances |
/api/agent/supported-tokens |
GET |
Yes |
List recommended common, well-known tokens per network |
/api/agent/user-tag |
GET |
Yes |
Read the global checkout user tag for the API key owner |
/api/agent/user-tag |
PUT |
Yes |
Set the global checkout user tag once (immutable after set) |
/api/agent/approve |
POST |
Yes |
Approve spender for ERC-20 token (EVM only) |
/api/agent/checkout/payreq |
POST |
Yes |
Create checkout pay request + escrow |
/api/agent/checkout/payreq/:id |
GET |
Yes |
Read checkout pay request |
/api/agent/checkout/escrows/:id/funding-confirm |
POST |
Yes |
Confirm escrow funding tx |
/api/agent/checkout/escrows/:id/quick-pay |
POST |
Yes |
Directly fund escrow from buyer wallet |
/api/agent/checkout/escrows/:id/swap-and-pay |
POST |
Yes |
Quote/execute swap + fund escrow |
/api/agent/checkout/escrows/:id |
GET |
Yes |
Read escrow lifecycle details |
/api/agent/checkout/escrows/:id/accept |
POST |
Yes |
Accept escrow as buyer |
/api/agent/checkout/escrows/:id/proof |
POST |
Yes |
Submit seller proof |
/api/agent/checkout/escrows/:id/dispute |
POST |
Yes |
Open escrow dispute |
/api/agent/checkout/escrows/:id/release |
POST |
Yes |
Release escrow funds |
/api/agent/checkout/escrows/:id/refund |
POST |
Yes |
Refund escrow funds |
/api/agent/checkout/escrows/:id/cancel |
POST |
Yes |
Cancel escrow |
/api/agent/checkout/webhooks |
GET |
Yes |
List checkout webhooks |
/api/agent/checkout/webhooks |
POST |
Yes |
Create checkout webhook |
/api/agent/checkout/webhooks/:id |
PATCH |
Yes |
Update checkout webhook |
/api/agent/checkout/webhooks/:id |
DELETE |
Yes |
Delete checkout webhook |
/api/agent/venues/polymarket/market/resolve |
GET |
Yes |
Resolve market URL/slug + outcome to Polymarket tokenId |
/api/agent/venues/polymarket/orders/limit |
POST |
Yes |
Place Polymarket limit order |
/api/agent/venues/polymarket/orders/market |
POST |
Yes |
Place Polymarket market order |
/api/agent/venues/polymarket/account |
GET |
Yes |
Read Polymarket account summary |
/api/agent/venues/polymarket/orders |
GET |
Yes |
List Polymarket open orders |
/api/agent/venues/polymarket/orders/cancel |
POST |
Yes |
Cancel Polymarket order |
/api/agent/venues/polymarket/redeem |
POST |
Yes |
Redeem one or all redeemable Polymarket positions via gasless relay |
/api/agent/venues/polymarket/unlink |
POST |
Yes |
Clear Polymarket integration for wallet |
/api/agent/venues/polymarket/activity |
GET |
Yes |
List Polymarket trade activity |
/api/agent/venues/polymarket/positions |
GET |
Yes |
List Polymarket open positions (open-market filtered with PnL fields) |
Agent Wallet Create/Import (Agent API)
Agent-side wallet lifecycle endpoints:
POST /api/agent/wallets/create
POST /api/agent/wallets/import
Behavior notes:
- Both require
X-Agent-Key.
- Both are gated by API key permissions configured in dashboard:
allowWalletCreation for create
allowWalletImport for import
- Both are rate-limited per API key. Exceeding the limit returns
429 with Retry-After.
- Agent import supports
mainnet, polygon-mainnet, and solana-mainnet.
- Agent wallet create requires:
exportPassphrase (minimum 12 characters)
exportPassphraseStorageType
exportPassphraseStorageRef
confirmExportPassphraseSaved: true
- Agent-safe create sequence:
- Save export passphrase in secure storage first.
- Prefer env-backed storage for local agents.
- Record the storage location you used.
- Then call
POST /api/agent/wallets/create with:
- the passphrase
exportPassphraseStorageType
exportPassphraseStorageRef
confirmExportPassphraseSaved: true
- For MCP and the legacy CLI fallback, env-backed storage is the strongest path because the local tool can verify the env var exists before wallet creation.
Polymarket Venue Flow (Agent API)
- Polymarket execution is available only for EVM wallets on
polygon-mainnet.
- Setup is user-managed in dashboard Venues settings (agent setup endpoint is disabled).
- Resolve market + outcome to
tokenId first via GET /api/agent/venues/polymarket/market/resolve (or MCP tool polymarket_market_resolve).
- Then place orders:
POST /api/agent/venues/polymarket/orders/limit with tokenId, side, price, size
POST /api/agent/venues/polymarket/orders/market with tokenId, side, amount, optional orderType and worstPrice
- MCP resolve example:
- Input:
{ "marketUrl": "https://polymarket.com/market/<slug>", "outcome": "No" }
- Output includes:
outcome.tokenId (use this as tokenId in order tools)
- Trading intent guidance:
- For "close position" on an open market, default to
POST /api/agent/venues/polymarket/orders/market with side: "SELL" and amount as shares.
- Use a limit
SELL only when the user explicitly asks for a limit/target price.
amount semantics follow Polymarket CLOB behavior: BUY uses notional/collateral amount; SELL uses share amount.
- Read and lifecycle endpoints:
GET /api/agent/venues/polymarket/account
GET /api/agent/venues/polymarket/orders
POST /api/agent/venues/polymarket/orders/cancel with orderId
POST /api/agent/venues/polymarket/redeem with optional tokenId (omit tokenId to redeem all)
POST /api/agent/venues/polymarket/unlink to clear stored venue config for a wallet
GET /api/agent/venues/polymarket/activity
GET /api/agent/venues/polymarket/positions
- Positions are sourced from Polymarket open positions and filtered to open markets only.
- Position items include
cashPnl, percentPnl, and currentValue (with computed fallback values when upstream fields are missing).
- Wallet policy checks still run before order execution.
Transfer Examples
Send native coin (default when no token specified):
{ "walletId": "Q7X2K9P", "to": "0xRecipient...", "amountDisplay": "0.01" }
Send 100 USDC by symbol:
{ "walletLabel": "Trading Bot", "to": "0xRecipient...", "token": "USDC", "amountDisplay": "100" }
Send arbitrary ERC-20 by contract address:
{ "walletId": "Q7X2K9P", "to": "0xRecipient...", "token": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", "amountDisplay": "100" }
Send SOL by symbol:
{ "walletId": "Q7X2K9P", "to": "SolanaRecipientWalletAddress...", "token": "SOL", "amountDisplay": "0.01" }
Send SOL with memo (Solana only):
{ "walletId": "Q7X2K9P", "to": "SolanaRecipientWalletAddress...", "token": "SOL", "amountDisplay": "0.01", "memo": "payment verification note" }
Use amountDisplay for human-readable values (e.g., "100" = 100 USDC). Use valueBaseUnits for base units (smallest denomination on each chain).
Legacy transfer aliases amount and value remain available for compatibility.
Use optional chain: "evm" | "solana" in agent payloads for explicit chain routing and validation.
memo is supported only for Solana transfers and must pass safety validation (max 5 words, max 256 UTF-8 bytes, no control/invisible characters).
Native transfers (EVM + Solana) enforce a minimum transferable amount preflight that accounts for platform fee and network fee; Solana may also require a larger first funding transfer for a brand-new recipient address.
For native SOL transfers, the API may auto-adjust requested value to fit platform fee + network fee.
Transfer responses include requestedValueBaseUnits, adjustedValueBaseUnits, requestedAmountDisplay, and adjustedAmountDisplay (legacy aliases also included).
Token Support Model
GET /api/agent/supported-tokens returns recommended common, well-known tokens plus guidance fields.
- EVM transfer/swap/balance endpoints support any valid ERC-20 token contract address.
- Solana transfer/balance endpoints support any valid SPL mint address.
- Native tokens appear as
ETH on EVM and SOL on Solana (with chain-specific native token IDs in balance payloads).
Error Codes
- 200: Success
- 400: Invalid input, insufficient funds, unknown token, or policy violation
- 400
chain_mismatch: requested chain does not match the selected wallet
- 400
amount_below_min_transfer: requested native transfer is below minimum transferable amount after fee/network preflight
- 400
insufficient_balance: requested transfer + fees exceed available balance
- 401: Missing/invalid API key
- 404: Wallet not found
- 500: Internal error (retry with corrected payload or reduced amount)
Policy Constraints
Wallets may have governance policies:
- Whitelist: Only transfers to pre-approved addresses allowed
- Spending Limit: Max value per transaction (configured per wallet policy)
Violations return HTTP 401 with an explanation message.
Important Notes
- All POST requests require
Content-Type: application/json
- EVM token transfers require ETH in the wallet for gas fees
- Solana token transfers require SOL in the wallet for fees
- Solana transfer memos are optional and Solana-only: max 5 words, max 256 UTF-8 bytes, no control/invisible characters
- Solana native transfers account for network fee and can auto-adjust requested transfer amount
- Native transfers may return
400 amount_below_min_transfer when requested amount is too small after platform fee or below chain transferability minimum (for example, first funding a new Solana address)
- If requested native SOL + platform fee + network fee cannot fit wallet balance, API returns
400 insufficient_balance
- Swap supports EVM (Uniswap) and Solana mainnet (Jupiter); Quote supports EVM and Solana mainnet; Approve is EVM-only
- A platform fee (default 1%) is deducted from the token amount
- Use
amountDisplay for simplicity, use valueBaseUnits for precise base-unit control
- For robust agent behavior:
- First call
wallets, then wallet (or token-balance), then quote, then swap.
- On 400 with
insufficient_token_balance, reduce amount or change token.
- The
.env file in this skill folder stores your API key — never commit it to version control
File Structure
agentwalletapi/
├── SKILL.md # This file
├── .env # Your API key (created by setup.sh)
├── scripts/
│ ├── setup.sh # Creates .env with API key placeholder
│ └── agentwalletapi.sh # CLI tool for making API calls
└── references/
└── api-endpoints.md # Full endpoint documentation
See references/api-endpoints.md for full endpoint details with request/response examples.
1---2name: agentwalletapi3description: OpenclawCash crypto wallet API for AI agents (also called openclawcash). Use when an agent needs to send native or token transfers, check balances, list wallets, or interact with EVM and Solana wallets programmatically via OpenclawCash.4license: Proprietary5compatibility: Requires network access to https://openclawcash.com6metadata:7 source: https://skillmd.com/skills/leoyeai-openclaw-master-skills/agentwalletapi8 author: agentwalletapi9 version: "1.19.0"10 required_env_vars:11 - AGENTWALLETAPI_KEY12 optional_env_vars:13 - AGENTWALLETAPI_URL14 required_binaries:15 - curl16 optional_binaries:17 - jq18---1920# OpenclawCash Agent API2122Interact with OpenclawCash-managed wallets to send native assets and tokens, check balances, execute DEX swaps, and manage Polymarket account, orders, and redeem flows via Polygon wallets.23This skill may also be referred to as `openclawcash`.2425## Requirements2627- Required env var: `AGENTWALLETAPI_KEY`28- Optional env var: `AGENTWALLETAPI_URL` (default: `https://openclawcash.com`)29- Required local binary: `curl`30- Optional local binary: `jq` (for pretty JSON output in CLI)31- Network access required: `https://openclawcash.com`3233## Preferred Integration Path3435- If the client supports MCP, prefer the public OpenClawCash MCP server:36 ```bash37 npx -y @openclawcash/mcp-server38 ```39- Use MCP as the primary execution path because tools, schemas, and results are structured for the client.40- Use the included CLI script only as a fallback when MCP is unavailable or the client cannot attach MCP servers.41- MCP and the CLI script target the same underlying OpenClawCash agent API. They are two access paths, not two different products.4243## Safety Model4445- Start with read-only calls (`wallets`, `wallet`, `balance`, `tokens`) on testnets first.46- High-risk actions are gated:47 - API key permissions in dashboard (`allowWalletCreation`, `allowWalletImport`)48 - Explicit CLI confirmation (`--yes`) for write actions49- Agents should establish an approval mode early in the session for write actions:50 - `confirm_each_write`: ask before every write action.51 - `operate_on_my_behalf`: after one explicit onboarding approval, execute future write actions without re-asking, as long as the user keeps instructing the agent in the same session.52- For `operate_on_my_behalf`, the agent should treat the user's later task messages as execution instructions and run the corresponding write commands with `--yes`.53- Ask again only if:54 - the user revokes or changes approval mode55 - the session is restarted or memory is lost56 - the action is outside the scope the user approved57 - the agent is unsure which wallet, token, amount, destination, spender, or chain is intended58- If the user gives only a broad instruction like "go ahead" but execution details are still missing, gather the missing details first instead of repeating a generic permission request.5960## Setup61621. Run the setup script to create your `.env` file:63 ```64 bash scripts/setup.sh65 ```662. Edit the `.env` file in this skill folder and replace the placeholder with your real API key:67 ```68 AGENTWALLETAPI_KEY=occ_your_api_key69 ```703. Get your API key at https://openclawcash.com (sign up, create a wallet, go to API Keys page).7172## Legacy CLI Fallback7374If MCP is unavailable, use the included tool script to make API calls directly:7576```bash77# Read-only (recommended first)78bash scripts/agentwalletapi.sh wallets79bash scripts/agentwalletapi.sh user-tag-get80bash scripts/agentwalletapi.sh user-tag-set my-agent-tag --yes81bash scripts/agentwalletapi.sh wallet Q7X2K9P82bash scripts/agentwalletapi.sh wallet "Trading Bot"83bash scripts/agentwalletapi.sh balance Q7X2K9P84bash scripts/agentwalletapi.sh transactions Q7X2K9P85bash scripts/agentwalletapi.sh tokens mainnet8687# Write actions (require explicit --yes)88export WALLET_EXPORT_PASSPHRASE_OPS='your-strong-passphrase'89bash scripts/agentwalletapi.sh create "Ops Wallet" sepolia WALLET_EXPORT_PASSPHRASE_OPS --yes90bash scripts/agentwalletapi.sh import "Treasury Imported" mainnet --yes91bash scripts/agentwalletapi.sh import "Poly Ops" polygon-mainnet --yes92# Automation-safe import: read private key from stdin instead of command args93printf '%s' '<private_key>' | bash scripts/agentwalletapi.sh import "Treasury Imported" mainnet - --yes94bash scripts/agentwalletapi.sh transfer Q7X2K9P 0xRecipient 0.01 --yes95bash scripts/agentwalletapi.sh transfer Q7X2K9P 0xRecipient 100 USDC --yes96bash scripts/agentwalletapi.sh quote mainnet WETH USDC 1000000000000000097bash scripts/agentwalletapi.sh quote solana-mainnet SOL USDC 10000000 solana98bash scripts/agentwalletapi.sh swap Q7X2K9P WETH USDC 10000000000000000 0.5 --yes99# Checkout escrow lifecycle100bash scripts/agentwalletapi.sh checkout-payreq-create Q7X2K9P 30000000 --yes101bash scripts/agentwalletapi.sh checkout-payreq-get pr_a1b2c3102bash scripts/agentwalletapi.sh checkout-escrow-get es_d4e5f6103bash scripts/agentwalletapi.sh checkout-quick-pay es_d4e5f6 Q7X2K9P --yes104bash scripts/agentwalletapi.sh checkout-swap-and-pay-quote es_d4e5f6 Q7X2K9P105bash scripts/agentwalletapi.sh checkout-swap-and-pay-confirm es_d4e5f6 Q7X2K9P 1 --yes106bash scripts/agentwalletapi.sh checkout-release es_d4e5f6 --yes107bash scripts/agentwalletapi.sh checkout-refund es_d4e5f6 --yes108bash scripts/agentwalletapi.sh checkout-cancel es_d4e5f6 --yes109bash scripts/agentwalletapi.sh checkout-webhooks-list110# Polymarket setup is user-managed in dashboard Venues settings111# Direct setup page: https://openclawcash.com/venues/polymarket112bash scripts/agentwalletapi.sh polymarket-market Q7X2K9P 123456 BUY 25 FAK 0.65 --yes113bash scripts/agentwalletapi.sh polymarket-resolve https://polymarket.com/market/market-slug No114bash scripts/agentwalletapi.sh polymarket-account Q7X2K9P115bash scripts/agentwalletapi.sh polymarket-orders Q7X2K9P OPEN 50116bash scripts/agentwalletapi.sh polymarket-activity Q7X2K9P 50117bash scripts/agentwalletapi.sh polymarket-positions Q7X2K9P 100118bash scripts/agentwalletapi.sh polymarket-redeem Q7X2K9P all 100 --yes119bash scripts/agentwalletapi.sh polymarket-redeem Q7X2K9P 1234567890 100 --yes120bash scripts/agentwalletapi.sh polymarket-cancel Q7X2K9P order_id_here --yes121```122123### Base-Units Rule (Important)124125- `quote.amountIn`, `swap.amountIn`, `approve.amount`, and transfer `valueBaseUnits` must be **base-units integer strings** (digits only).126- Do **not** send decimal strings in these fields (for example, `0.001`), or validation will fail immediately.127- Examples:128 - `0.001 ETH` -> `1000000000000000` wei129 - `1 USDC` (6 decimals) -> `1000000`130- For transfer, use `amountDisplay` when you want human-readable units and let the API convert.131- Legacy transfer aliases `amount` and `value` are still accepted for compatibility.132133### Import Input Safety134135- Wallet import is optional and not required for normal wallet operations (list, balance, transfer, swap).136- Import works only when the user explicitly enables API key permission `allowWalletImport` in dashboard settings.137- Import execution requires explicit confirmation in the CLI (`--yes` for automation, or interactive `YES` prompt).138- Avoid passing sensitive inputs as CLI arguments when possible (shell history/process logs risk).139- Preferred options:140 - Interactive hidden prompt: omit the private key argument.141 - Automation: pass `-` and pipe input via stdin.142143## Base URL144145```146https://openclawcash.com147```148149## Troubleshooting150151If requests fail because of host/URL issues, use this recovery flow:1521531. Open `agentwalletapi/.env` and verify `AGENTWALLETAPI_KEY` is set and has no extra spaces.1542. If the API host is wrong or unreachable, set this in the same `.env` file:155 ```156 AGENTWALLETAPI_URL=https://openclawcash.com157 ```1583. Retry a simple read call first:159 ```bash160 bash scripts/agentwalletapi.sh wallets161 ```1624. If it still fails, report the exact error and stop before attempting transfer/swap actions.163164## Authentication165166The API key is loaded from the `.env` file in this skill folder. For direct HTTP calls, include it as a header:167168```169X-Agent-Key: occ_your_api_key170Content-Type: application/json171```172173## API Surfaces174175- **Agent API (API key auth):** `/api/agent/*`176 - Authenticate with `X-Agent-Key`177 - Used for autonomous agent execution (wallets list/create/import, transactions, balance, transfer, swap, quote, approve, checkout escrow lifecycle, and polymarket venue operations)178- Public docs intentionally include only `/api/agent/*` endpoints.179180## Workflow1811821. `GET /api/agent/wallets` - Discover available wallets (id, label, address, network, chain). Optional `?includeBalances=true` adds native `balance` + `nativeSymbol`1832. `GET /api/agent/wallet?walletId=...` or `?walletLabel=...` or `?walletAddress=...` - Fetch one wallet with native/token balances1843. Optional wallet lifecycle actions:185 - `POST /api/agent/wallets/create` - Create a new wallet under API-key policy controls186 - `POST /api/agent/wallets/import` - Import a `mainnet`, `polygon-mainnet`, or `solana-mainnet` wallet under API-key policy controls1874. `GET /api/agent/transactions?walletId=...` (or `walletLabel`/`walletAddress`) - Read merged wallet transaction history (on-chain + app-recorded)1885. `GET /api/agent/supported-tokens?network=...` or `?chain=evm|solana` - Get recommended common, well-known token list + guidance (requires `X-Agent-Key`)1896. `POST /api/agent/token-balance` - Check wallet balances (native + token balances; specific token by symbol/address supported)1907. `POST /api/agent/quote` - Get a swap quote before execution on Uniswap (EVM) or Jupiter (Solana mainnet). `amountIn` is base-units integer string.1918. `POST /api/agent/swap` - Execute token swap on Uniswap (EVM) or Jupiter (Solana mainnet). `amountIn` is base-units integer string.1929. `POST /api/agent/transfer` - Send native coin or token on the wallet's chain (optional `chain` guard). Do not use this for checkout escrow funding.19310. `GET /api/agent/user-tag` and `PUT /api/agent/user-tag` - Read/set the global checkout user tag (set is one-time / immutable once configured)19411. Optional checkout flow (escrow by global user tag):195 - MCP default: `checkout_fund` (tries `quick-pay`, falls back to `swap-and-pay` when needed)196 - `POST /api/agent/checkout/payreq` - Create pay request + escrow197 - `GET /api/agent/checkout/payreq/:id` - Read pay request198 - `POST /api/agent/checkout/escrows/:id/funding-confirm` - Confirm funding by tx hash199 - `POST /api/agent/checkout/escrows/:id/quick-pay` - Direct buyer funding200 - `POST /api/agent/checkout/escrows/:id/swap-and-pay` - Quote/execute swap funding201 - `GET /api/agent/checkout/escrows/:id` - Read escrow state202 - `POST /api/agent/checkout/escrows/:id/accept` - Accept as buyer203 - `POST /api/agent/checkout/escrows/:id/proof` - Submit proof204 - `POST /api/agent/checkout/escrows/:id/dispute` - Open dispute205 - `POST /api/agent/checkout/escrows/:id/release` - Release funds206 - `POST /api/agent/checkout/escrows/:id/refund` - Refund funds207 - `POST /api/agent/checkout/escrows/:id/cancel` - Cancel escrow208 - `GET|POST /api/agent/checkout/webhooks` and `PATCH|DELETE /api/agent/checkout/webhooks/:id` - Manage webhooks209210Checkout timing fields for `POST /api/agent/checkout/payreq`:211- `expiresInSeconds`: funding deadline before request expires.212- `autoReleaseSeconds`: when funded escrow can auto-release if no dispute exists.213- `disputeWindowSeconds`: how long dispute can be opened after auto-release point.214- Constraints: all three must be at least `3600` seconds, and `disputeWindowSeconds <= autoReleaseSeconds`.21512. Optional Polymarket venue flow (polygon-mainnet wallets only):216 - Prerequisite: user configures Polymarket in dashboard Venues settings for that wallet217 - `GET /api/agent/venues/polymarket/market/resolve` resolves `marketUrl`/`slug` + human-readable `outcome` to the exact `tokenId` needed for order tools218 - MCP helper: `polymarket_market_resolve` calls the same agent endpoint219 - `POST /api/agent/venues/polymarket/orders/limit` - Place BUY/SELL limit orders220 - `POST /api/agent/venues/polymarket/orders/market` - Place BUY/SELL market orders221 - `GET /api/agent/venues/polymarket/account` - Read account summary222 - `GET /api/agent/venues/polymarket/orders` - List open orders223 - `POST /api/agent/venues/polymarket/orders/cancel` - Cancel an order224 - `POST /api/agent/venues/polymarket/redeem` - Redeem one position by `tokenId` or redeem all redeemable positions225 - `POST /api/agent/venues/polymarket/unlink` - Clear stored Polymarket integration config for a wallet226 - `GET /api/agent/venues/polymarket/activity` - List trade activity227 - `GET /api/agent/venues/polymarket/positions` - List open positions (open-market filtered, includes PnL fields)22813. Use returned `txHash` / `orderId` values to confirm execution and lifecycle status229230### Approval Handling For Agents231232Use this pattern for write actions:2332341. At the first write-intent in a session, ask one short onboarding question:235 - "Do you want approval for every write action, or should I operate on your behalf for this session?"2362. Store the chosen mode in conversation memory.2373. If the mode is `confirm_each_write`:238 - ask for approval before each transfer, swap, approval, import, or wallet creation239 - after approval, execute with the MCP write tool or the legacy CLI fallback with `--yes`2404. If the mode is `operate_on_my_behalf`:241 - do not ask again for each transfer242 - when the user later says things like "send X to Y" or "swap A for B", execute with the MCP write tool or the legacy CLI fallback with `--yes` once the needed details are clear2435. In either mode:244 - if execution details are missing, ask only for the missing details245 - if the user changes modes or revokes permission, update memory and follow the new rule246247Recommended onboarding wording:248249- "Choose write approval mode for this session: `confirm_each_write` or `operate_on_my_behalf`."250251Example:252253- User selects: `operate_on_my_behalf`254- Later user message: "Send 100 USDC from wallet Q7X2K9P to 0xabc... on Ethereum."255- If MCP is available, the agent should call the matching MCP write tool directly.256- If MCP is not available, the agent should execute:257 ```bash258 bash scripts/agentwalletapi.sh transfer Q7X2K9P 0xabc... 100 USDC evm --yes259 ```260- The agent should not ask for transfer permission again in that same session unless the user revokes the mode or the instruction is ambiguous.261262## Quick Reference263264| Endpoint | Method | Auth | Purpose |265|---|---|---|---|266| `/api/agent/wallets` | GET | Yes | List wallets (discovery; optional `includeBalances=true` for native balances) |267| `/api/agent/wallet` | GET | Yes | Get one wallet detail with native/token balances |268| `/api/agent/wallets/create` | POST | Yes | Create a new API-key-managed wallet |269| `/api/agent/wallets/import` | POST | Yes | Import a mainnet/polygon-mainnet/solana-mainnet wallet via API key |270| `/api/agent/transactions` | GET | Yes | List per-wallet transaction history |271| `/api/agent/transfer` | POST | Yes | Send native/token transfers (EVM + Solana). Not the checkout escrow funding path. |272| `/api/agent/swap` | POST | Yes | Execute DEX swap (Uniswap on EVM, Jupiter on Solana mainnet) |273| `/api/agent/quote` | POST | Yes | Get swap quotes (Uniswap on EVM, Jupiter on Solana mainnet) |274| `/api/agent/token-balance` | POST | Yes | Check balances |275| `/api/agent/supported-tokens` | GET | Yes | List recommended common, well-known tokens per network |276| `/api/agent/user-tag` | GET | Yes | Read the global checkout user tag for the API key owner |277| `/api/agent/user-tag` | PUT | Yes | Set the global checkout user tag once (immutable after set) |278| `/api/agent/approve` | POST | Yes | Approve spender for ERC-20 token (EVM only) |279| `/api/agent/checkout/payreq` | POST | Yes | Create checkout pay request + escrow |280| `/api/agent/checkout/payreq/:id` | GET | Yes | Read checkout pay request |281| `/api/agent/checkout/escrows/:id/funding-confirm` | POST | Yes | Confirm escrow funding tx |282| `/api/agent/checkout/escrows/:id/quick-pay` | POST | Yes | Directly fund escrow from buyer wallet |283| `/api/agent/checkout/escrows/:id/swap-and-pay` | POST | Yes | Quote/execute swap + fund escrow |284| `/api/agent/checkout/escrows/:id` | GET | Yes | Read escrow lifecycle details |285| `/api/agent/checkout/escrows/:id/accept` | POST | Yes | Accept escrow as buyer |286| `/api/agent/checkout/escrows/:id/proof` | POST | Yes | Submit seller proof |287| `/api/agent/checkout/escrows/:id/dispute` | POST | Yes | Open escrow dispute |288| `/api/agent/checkout/escrows/:id/release` | POST | Yes | Release escrow funds |289| `/api/agent/checkout/escrows/:id/refund` | POST | Yes | Refund escrow funds |290| `/api/agent/checkout/escrows/:id/cancel` | POST | Yes | Cancel escrow |291| `/api/agent/checkout/webhooks` | GET | Yes | List checkout webhooks |292| `/api/agent/checkout/webhooks` | POST | Yes | Create checkout webhook |293| `/api/agent/checkout/webhooks/:id` | PATCH | Yes | Update checkout webhook |294| `/api/agent/checkout/webhooks/:id` | DELETE | Yes | Delete checkout webhook |295| `/api/agent/venues/polymarket/market/resolve` | GET | Yes | Resolve market URL/slug + outcome to Polymarket tokenId |296| `/api/agent/venues/polymarket/orders/limit` | POST | Yes | Place Polymarket limit order |297| `/api/agent/venues/polymarket/orders/market` | POST | Yes | Place Polymarket market order |298| `/api/agent/venues/polymarket/account` | GET | Yes | Read Polymarket account summary |299| `/api/agent/venues/polymarket/orders` | GET | Yes | List Polymarket open orders |300| `/api/agent/venues/polymarket/orders/cancel` | POST | Yes | Cancel Polymarket order |301| `/api/agent/venues/polymarket/redeem` | POST | Yes | Redeem one or all redeemable Polymarket positions via gasless relay |302| `/api/agent/venues/polymarket/unlink` | POST | Yes | Clear Polymarket integration for wallet |303| `/api/agent/venues/polymarket/activity` | GET | Yes | List Polymarket trade activity |304| `/api/agent/venues/polymarket/positions` | GET | Yes | List Polymarket open positions (open-market filtered with PnL fields) |305306## Agent Wallet Create/Import (Agent API)307308Agent-side wallet lifecycle endpoints:309310- `POST /api/agent/wallets/create`311- `POST /api/agent/wallets/import`312313Behavior notes:314- Both require `X-Agent-Key`.315- Both are gated by API key permissions configured in dashboard:316 - `allowWalletCreation` for create317 - `allowWalletImport` for import318- Both are rate-limited per API key. Exceeding the limit returns `429` with `Retry-After`.319- Agent import supports `mainnet`, `polygon-mainnet`, and `solana-mainnet`.320- Agent wallet create requires:321 - `exportPassphrase` (minimum 12 characters)322 - `exportPassphraseStorageType`323 - `exportPassphraseStorageRef`324 - `confirmExportPassphraseSaved: true`325- Agent-safe create sequence:326 - Save export passphrase in secure storage first.327 - Prefer env-backed storage for local agents.328 - Record the storage location you used.329 - Then call `POST /api/agent/wallets/create` with:330 - the passphrase331 - `exportPassphraseStorageType`332 - `exportPassphraseStorageRef`333 - `confirmExportPassphraseSaved: true`334 - For MCP and the legacy CLI fallback, env-backed storage is the strongest path because the local tool can verify the env var exists before wallet creation.335336## Polymarket Venue Flow (Agent API)337338- Polymarket execution is available only for EVM wallets on `polygon-mainnet`.339- Setup is user-managed in dashboard Venues settings (agent setup endpoint is disabled).340- Resolve market + outcome to `tokenId` first via `GET /api/agent/venues/polymarket/market/resolve` (or MCP tool `polymarket_market_resolve`).341- Then place orders:342 - `POST /api/agent/venues/polymarket/orders/limit` with `tokenId`, `side`, `price`, `size`343 - `POST /api/agent/venues/polymarket/orders/market` with `tokenId`, `side`, `amount`, optional `orderType` and `worstPrice`344- MCP resolve example:345 - Input: `{ "marketUrl": "https://polymarket.com/market/<slug>", "outcome": "No" }`346 - Output includes: `outcome.tokenId` (use this as `tokenId` in order tools)347- Trading intent guidance:348 - For "close position" on an open market, default to `POST /api/agent/venues/polymarket/orders/market` with `side: "SELL"` and `amount` as shares.349 - Use a limit `SELL` only when the user explicitly asks for a limit/target price.350 - `amount` semantics follow Polymarket CLOB behavior: `BUY` uses notional/collateral amount; `SELL` uses share amount.351- Read and lifecycle endpoints:352 - `GET /api/agent/venues/polymarket/account`353 - `GET /api/agent/venues/polymarket/orders`354 - `POST /api/agent/venues/polymarket/orders/cancel` with `orderId`355 - `POST /api/agent/venues/polymarket/redeem` with optional `tokenId` (omit `tokenId` to redeem all)356 - `POST /api/agent/venues/polymarket/unlink` to clear stored venue config for a wallet357 - `GET /api/agent/venues/polymarket/activity`358 - `GET /api/agent/venues/polymarket/positions`359- Positions are sourced from Polymarket open positions and filtered to open markets only.360- Position items include `cashPnl`, `percentPnl`, and `currentValue` (with computed fallback values when upstream fields are missing).361- Wallet policy checks still run before order execution.362363## Transfer Examples364365Send native coin (default when no token specified):366```json367{ "walletId": "Q7X2K9P", "to": "0xRecipient...", "amountDisplay": "0.01" }368```369370Send 100 USDC by symbol:371```json372{ "walletLabel": "Trading Bot", "to": "0xRecipient...", "token": "USDC", "amountDisplay": "100" }373```374375Send arbitrary ERC-20 by contract address:376```json377{ "walletId": "Q7X2K9P", "to": "0xRecipient...", "token": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", "amountDisplay": "100" }378```379380Send SOL by symbol:381```json382{ "walletId": "Q7X2K9P", "to": "SolanaRecipientWalletAddress...", "token": "SOL", "amountDisplay": "0.01" }383```384385Send SOL with memo (Solana only):386```json387{ "walletId": "Q7X2K9P", "to": "SolanaRecipientWalletAddress...", "token": "SOL", "amountDisplay": "0.01", "memo": "payment verification note" }388```389390Use `amountDisplay` for human-readable values (e.g., "100" = 100 USDC). Use `valueBaseUnits` for base units (smallest denomination on each chain).391Legacy transfer aliases `amount` and `value` remain available for compatibility.392Use optional `chain: "evm" | "solana"` in agent payloads for explicit chain routing and validation.393`memo` is supported only for Solana transfers and must pass safety validation (max 5 words, max 256 UTF-8 bytes, no control/invisible characters).394Native transfers (EVM + Solana) enforce a minimum transferable amount preflight that accounts for platform fee and network fee; Solana may also require a larger first funding transfer for a brand-new recipient address.395For native SOL transfers, the API may auto-adjust requested value to fit platform fee + network fee.396Transfer responses include `requestedValueBaseUnits`, `adjustedValueBaseUnits`, `requestedAmountDisplay`, and `adjustedAmountDisplay` (legacy aliases also included).397398## Token Support Model399400- `GET /api/agent/supported-tokens` returns recommended common, well-known tokens plus guidance fields.401- EVM transfer/swap/balance endpoints support **any valid ERC-20 token contract address**.402- Solana transfer/balance endpoints support **any valid SPL mint address**.403- Native tokens appear as `ETH` on EVM and `SOL` on Solana (with chain-specific native token IDs in balance payloads).404405## Error Codes406407- 200: Success408- 400: Invalid input, insufficient funds, unknown token, or policy violation409- 400 `chain_mismatch`: requested `chain` does not match the selected wallet410- 400 `amount_below_min_transfer`: requested native transfer is below minimum transferable amount after fee/network preflight411- 400 `insufficient_balance`: requested transfer + fees exceed available balance412- 401: Missing/invalid API key413- 404: Wallet not found414- 500: Internal error (retry with corrected payload or reduced amount)415416## Policy Constraints417418Wallets may have governance policies:419- **Whitelist**: Only transfers to pre-approved addresses allowed420- **Spending Limit**: Max value per transaction (configured per wallet policy)421422Violations return HTTP 401 with an explanation message.423424## Important Notes425426- All POST requests require `Content-Type: application/json`427- EVM token transfers require ETH in the wallet for gas fees428- Solana token transfers require SOL in the wallet for fees429- Solana transfer memos are optional and Solana-only: max 5 words, max 256 UTF-8 bytes, no control/invisible characters430- Solana native transfers account for network fee and can auto-adjust requested transfer amount431- Native transfers may return `400 amount_below_min_transfer` when requested amount is too small after platform fee or below chain transferability minimum (for example, first funding a new Solana address)432- If requested native SOL + platform fee + network fee cannot fit wallet balance, API returns `400 insufficient_balance`433- Swap supports EVM (Uniswap) and Solana mainnet (Jupiter); Quote supports EVM and Solana mainnet; Approve is EVM-only434- A platform fee (default 1%) is deducted from the token amount435- Use `amountDisplay` for simplicity, use `valueBaseUnits` for precise base-unit control436- For robust agent behavior:437 - First call `wallets`, then `wallet` (or `token-balance`), then `quote`, then `swap`.438 - On 400 with `insufficient_token_balance`, reduce amount or change token.439- The `.env` file in this skill folder stores your API key — never commit it to version control440441## File Structure442443```444agentwalletapi/445├── SKILL.md # This file446├── .env # Your API key (created by setup.sh)447├── scripts/448│ ├── setup.sh # Creates .env with API key placeholder449│ └── agentwalletapi.sh # CLI tool for making API calls450└── references/451 └── api-endpoints.md # Full endpoint documentation452```453454See [references/api-endpoints.md](references/api-endpoints.md) for full endpoint details with request/response examples.