OpenclawCash Agent API
Interact with OpenclawCash-managed wallets to send native assets and tokens, check balances, and execute agent-safe wallet operations across EVM and Solana networks.
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 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
# 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
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)
- Dashboard/User API (session auth):
/api/wallets/*
- Authenticate with bearer token or
aw_session cookie
- Used for user-managed dashboard operations (including wallet import and wallet creation).
- Dashboard wallet creation now requires
exportPassphrase (minimum 12 characters).
- Private-key export requires
exportPassphrase and is protected by rate limits and temporary lockouts.
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 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)
POST /api/agent/swap - Execute token swap on Uniswap (EVM) or Jupiter (Solana mainnet)
POST /api/agent/transfer - Send native coin or token on the wallet's chain (optional chain guard)
- Use returned
txHash values to confirm transactions
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/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) |
/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/approve |
POST |
Yes |
Approve spender for ERC-20 token (EVM only) |
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 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.
Transfer Examples
Send native coin (default when no token specified):
{ "walletId": "Q7X2K9P", "to": "0xRecipient...", "amount": "0.01" }
Send 100 USDC by symbol:
{ "walletLabel": "Trading Bot", "to": "0xRecipient...", "token": "USDC", "amount": "100" }
Send arbitrary ERC-20 by contract address:
{ "walletId": "Q7X2K9P", "to": "0xRecipient...", "token": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", "amount": "100" }
Send SOL by symbol:
{ "walletId": "Q7X2K9P", "to": "SolanaRecipientWalletAddress...", "token": "SOL", "amount": "0.01" }
Send SOL with memo (Solana only):
{ "walletId": "Q7X2K9P", "to": "SolanaRecipientWalletAddress...", "token": "SOL", "amount": "0.01", "memo": "payment verification note" }
Use amount for human-readable values (e.g., "100" = 100 USDC). Use value for base units (smallest denomination on each chain).
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 requestedValue, adjustedValue, requestedAmount, and adjustedAmount.
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
amount for simplicity, use value 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: agentwalletapi
3description: OpenclawCash crypto wallet API for AI agents. 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: Proprietary
5compatibility: Requires network access to https://openclawcash.com
6metadata:
7 source: https://skillmd.com/skills/modbender/agentwalletapi
8 author: agentwalletapi
9 version: "1.9.6"
10 required_env_vars:
11 - AGENTWALLETAPI_KEY
12 optional_env_vars:
13 - AGENTWALLETAPI_URL
14 required_binaries:
15 - curl
16 optional_binaries:
17 - jq
18---
19
20# OpenclawCash Agent API
21
22Interact with OpenclawCash-managed wallets to send native assets and tokens, check balances, and execute agent-safe wallet operations across EVM and Solana networks.
23
24## Requirements
25
26- Required env var: `AGENTWALLETAPI_KEY`
27- Optional env var: `AGENTWALLETAPI_URL` (default: `https://openclawcash.com`)
28- Required local binary: `curl`
29- Optional local binary: `jq` (for pretty JSON output in CLI)
30- Network access required: `https://openclawcash.com`
31
32## Preferred Integration Path
33
34- If the client supports MCP, prefer the public OpenClawCash MCP server:
35 ```bash
36 npx -y @openclawcash/mcp-server
37 ```
38- Use MCP as the primary execution path because tools, schemas, and results are structured for the client.
39- Use the included CLI script only as a fallback when MCP is unavailable or the client cannot attach MCP servers.
40- MCP and the CLI script target the same underlying OpenClawCash agent API. They are two access paths, not two different products.
41
42## Safety Model
43
44- Start with read-only calls (`wallets`, `wallet`, `balance`, `tokens`) on testnets first.
45- High-risk actions are gated:
46 - API key permissions in dashboard (`allowWalletCreation`, `allowWalletImport`)
47 - Explicit CLI confirmation (`--yes`) for write actions
48- Agents should establish an approval mode early in the session for write actions:
49 - `confirm_each_write`: ask before every write action.
50 - `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.
51- 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`.
52- Ask again only if:
53 - the user revokes or changes approval mode
54 - the session is restarted or memory is lost
55 - the action is outside the scope the user approved
56 - the agent is unsure which wallet, token, amount, destination, spender, or chain is intended
57- 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.
58
59## Setup
60
611. Run the setup script to create your `.env` file:
62 ```
63 bash scripts/setup.sh
64 ```
652. Edit the `.env` file in this skill folder and replace the placeholder with your real API key:
66 ```
67 AGENTWALLETAPI_KEY=occ_your_api_key
68 ```
693. Get your API key at https://openclawcash.com (sign up, create a wallet, go to API Keys page).
70
71## Legacy CLI Fallback
72
73If MCP is unavailable, use the included tool script to make API calls directly:
74
75```bash
76# Read-only (recommended first)
77bash scripts/agentwalletapi.sh wallets
78bash scripts/agentwalletapi.sh wallet Q7X2K9P
79bash scripts/agentwalletapi.sh wallet "Trading Bot"
80bash scripts/agentwalletapi.sh balance Q7X2K9P
81bash scripts/agentwalletapi.sh transactions Q7X2K9P
82bash scripts/agentwalletapi.sh tokens mainnet
83
84# Write actions (require explicit --yes)
85export WALLET_EXPORT_PASSPHRASE_OPS='your-strong-passphrase'
86bash scripts/agentwalletapi.sh create "Ops Wallet" sepolia WALLET_EXPORT_PASSPHRASE_OPS --yes
87bash scripts/agentwalletapi.sh import "Treasury Imported" mainnet --yes
88# Automation-safe import: read private key from stdin instead of command args
89printf '%s' '<private_key>' | bash scripts/agentwalletapi.sh import "Treasury Imported" mainnet - --yes
90bash scripts/agentwalletapi.sh transfer Q7X2K9P 0xRecipient 0.01 --yes
91bash scripts/agentwalletapi.sh transfer Q7X2K9P 0xRecipient 100 USDC --yes
92bash scripts/agentwalletapi.sh quote mainnet WETH USDC 10000000000000000
93bash scripts/agentwalletapi.sh quote solana-mainnet SOL USDC 10000000 solana
94bash scripts/agentwalletapi.sh swap Q7X2K9P WETH USDC 10000000000000000 0.5 --yes
95```
96
97### Import Input Safety
98
99- Wallet import is optional and not required for normal wallet operations (list, balance, transfer, swap).
100- Import works only when the user explicitly enables API key permission `allowWalletImport` in dashboard settings.
101- Import execution requires explicit confirmation in the CLI (`--yes` for automation, or interactive `YES` prompt).
102- Avoid passing sensitive inputs as CLI arguments when possible (shell history/process logs risk).
103- Preferred options:
104 - Interactive hidden prompt: omit the private key argument.
105 - Automation: pass `-` and pipe input via stdin.
106
107## Base URL
108
109```
110https://openclawcash.com
111```
112
113## Troubleshooting
114
115If requests fail because of host/URL issues, use this recovery flow:
116
1171. Open `agentwalletapi/.env` and verify `AGENTWALLETAPI_KEY` is set and has no extra spaces.
1182. If the API host is wrong or unreachable, set this in the same `.env` file:
119 ```
120 AGENTWALLETAPI_URL=https://openclawcash.com
121 ```
1223. Retry a simple read call first:
123 ```bash
124 bash scripts/agentwalletapi.sh wallets
125 ```
1264. If it still fails, report the exact error and stop before attempting transfer/swap actions.
127
128## Authentication
129
130The API key is loaded from the `.env` file in this skill folder. For direct HTTP calls, include it as a header:
131
132```
133X-Agent-Key: occ_your_api_key
134Content-Type: application/json
135```
136
137## API Surfaces
138
139- **Agent API (API key auth):** `/api/agent/*`
140 - Authenticate with `X-Agent-Key`
141 - Used for autonomous agent execution (wallets list/create/import, transactions, balance, transfer, swap, quote, approve)
142- **Dashboard/User API (session auth):** `/api/wallets/*`
143 - Authenticate with bearer token or `aw_session` cookie
144 - Used for user-managed dashboard operations (including wallet import and wallet creation).
145 - Dashboard wallet creation now requires `exportPassphrase` (minimum 12 characters).
146 - Private-key export requires `exportPassphrase` and is protected by rate limits and temporary lockouts.
147
148## Workflow
149
1501. `GET /api/agent/wallets` - Discover available wallets (id, label, address, network, chain). Optional `?includeBalances=true` adds native `balance` + `nativeSymbol`
1512. `GET /api/agent/wallet?walletId=...` or `?walletLabel=...` or `?walletAddress=...` - Fetch one wallet with native/token balances
1523. Optional wallet lifecycle actions:
153 - `POST /api/agent/wallets/create` - Create a new wallet under API-key policy controls
154 - `POST /api/agent/wallets/import` - Import a `mainnet` or `solana-mainnet` wallet under API-key policy controls
1554. `GET /api/agent/transactions?walletId=...` (or `walletLabel`/`walletAddress`) - Read merged wallet transaction history (on-chain + app-recorded)
1565. `GET /api/agent/supported-tokens?network=...` or `?chain=evm|solana` - Get recommended common, well-known token list + guidance (requires `X-Agent-Key`)
1576. `POST /api/agent/token-balance` - Check wallet balances (native + token balances; specific token by symbol/address supported)
1587. `POST /api/agent/quote` - Get a swap quote before execution on Uniswap (EVM) or Jupiter (Solana mainnet)
1598. `POST /api/agent/swap` - Execute token swap on Uniswap (EVM) or Jupiter (Solana mainnet)
1609. `POST /api/agent/transfer` - Send native coin or token on the wallet's chain (optional `chain` guard)
16110. Use returned `txHash` values to confirm transactions
162
163### Approval Handling For Agents
164
165Use this pattern for write actions:
166
1671. At the first write-intent in a session, ask one short onboarding question:
168 - "Do you want approval for every write action, or should I operate on your behalf for this session?"
1692. Store the chosen mode in conversation memory.
1703. If the mode is `confirm_each_write`:
171 - ask for approval before each transfer, swap, approval, import, or wallet creation
172 - after approval, execute with the MCP write tool or the legacy CLI fallback with `--yes`
1734. If the mode is `operate_on_my_behalf`:
174 - do not ask again for each transfer
175 - 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
1765. In either mode:
177 - if execution details are missing, ask only for the missing details
178 - if the user changes modes or revokes permission, update memory and follow the new rule
179
180Recommended onboarding wording:
181
182- "Choose write approval mode for this session: `confirm_each_write` or `operate_on_my_behalf`."
183
184Example:
185
186- User selects: `operate_on_my_behalf`
187- Later user message: "Send 100 USDC from wallet Q7X2K9P to 0xabc... on Ethereum."
188- If MCP is available, the agent should call the matching MCP write tool directly.
189- If MCP is not available, the agent should execute:
190 ```bash
191 bash scripts/agentwalletapi.sh transfer Q7X2K9P 0xabc... 100 USDC evm --yes
192 ```
193- The agent should not ask for transfer permission again in that same session unless the user revokes the mode or the instruction is ambiguous.
194
195## Quick Reference
196
197| Endpoint | Method | Auth | Purpose |
198|---|---|---|---|
199| `/api/agent/wallets` | GET | Yes | List wallets (discovery; optional `includeBalances=true` for native balances) |
200| `/api/agent/wallet` | GET | Yes | Get one wallet detail with native/token balances |
201| `/api/agent/wallets/create` | POST | Yes | Create a new API-key-managed wallet |
202| `/api/agent/wallets/import` | POST | Yes | Import a mainnet/solana-mainnet wallet via API key |
203| `/api/agent/transactions` | GET | Yes | List per-wallet transaction history |
204| `/api/agent/transfer` | POST | Yes | Send native/token transfers (EVM + Solana) |
205| `/api/agent/swap` | POST | Yes | Execute DEX swap (Uniswap on EVM, Jupiter on Solana mainnet) |
206| `/api/agent/quote` | POST | Yes | Get swap quotes (Uniswap on EVM, Jupiter on Solana mainnet) |
207| `/api/agent/token-balance` | POST | Yes | Check balances |
208| `/api/agent/supported-tokens` | GET | Yes | List recommended common, well-known tokens per network |
209| `/api/agent/approve` | POST | Yes | Approve spender for ERC-20 token (EVM only) |
210
211## Agent Wallet Create/Import (Agent API)
212
213Agent-side wallet lifecycle endpoints:
214
215- `POST /api/agent/wallets/create`
216- `POST /api/agent/wallets/import`
217
218Behavior notes:
219- Both require `X-Agent-Key`.
220- Both are gated by API key permissions configured in dashboard:
221 - `allowWalletCreation` for create
222 - `allowWalletImport` for import
223- Both are rate-limited per API key. Exceeding the limit returns `429` with `Retry-After`.
224- Agent import supports `mainnet` and `solana-mainnet`.
225- Agent wallet create requires:
226 - `exportPassphrase` (minimum 12 characters)
227 - `exportPassphraseStorageType`
228 - `exportPassphraseStorageRef`
229 - `confirmExportPassphraseSaved: true`
230- Agent-safe create sequence:
231 - Save export passphrase in secure storage first.
232 - Prefer env-backed storage for local agents.
233 - Record the storage location you used.
234 - Then call `POST /api/agent/wallets/create` with:
235 - the passphrase
236 - `exportPassphraseStorageType`
237 - `exportPassphraseStorageRef`
238 - `confirmExportPassphraseSaved: true`
239 - 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.
240
241## Transfer Examples
242
243Send native coin (default when no token specified):
244```json
245{ "walletId": "Q7X2K9P", "to": "0xRecipient...", "amount": "0.01" }
246```
247
248Send 100 USDC by symbol:
249```json
250{ "walletLabel": "Trading Bot", "to": "0xRecipient...", "token": "USDC", "amount": "100" }
251```
252
253Send arbitrary ERC-20 by contract address:
254```json
255{ "walletId": "Q7X2K9P", "to": "0xRecipient...", "token": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", "amount": "100" }
256```
257
258Send SOL by symbol:
259```json
260{ "walletId": "Q7X2K9P", "to": "SolanaRecipientWalletAddress...", "token": "SOL", "amount": "0.01" }
261```
262
263Send SOL with memo (Solana only):
264```json
265{ "walletId": "Q7X2K9P", "to": "SolanaRecipientWalletAddress...", "token": "SOL", "amount": "0.01", "memo": "payment verification note" }
266```
267
268Use `amount` for human-readable values (e.g., "100" = 100 USDC). Use `value` for base units (smallest denomination on each chain).
269Use optional `chain: "evm" | "solana"` in agent payloads for explicit chain routing and validation.
270`memo` is supported only for Solana transfers and must pass safety validation (max 5 words, max 256 UTF-8 bytes, no control/invisible characters).
271Native 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.
272For native SOL transfers, the API may auto-adjust requested value to fit platform fee + network fee.
273Transfer responses include `requestedValue`, `adjustedValue`, `requestedAmount`, and `adjustedAmount`.
274
275## Token Support Model
276
277- `GET /api/agent/supported-tokens` returns recommended common, well-known tokens plus guidance fields.
278- EVM transfer/swap/balance endpoints support **any valid ERC-20 token contract address**.
279- Solana transfer/balance endpoints support **any valid SPL mint address**.
280- Native tokens appear as `ETH` on EVM and `SOL` on Solana (with chain-specific native token IDs in balance payloads).
281
282## Error Codes
283
284- 200: Success
285- 400: Invalid input, insufficient funds, unknown token, or policy violation
286- 400 `chain_mismatch`: requested `chain` does not match the selected wallet
287- 400 `amount_below_min_transfer`: requested native transfer is below minimum transferable amount after fee/network preflight
288- 400 `insufficient_balance`: requested transfer + fees exceed available balance
289- 401: Missing/invalid API key
290- 404: Wallet not found
291- 500: Internal error (retry with corrected payload or reduced amount)
292
293## Policy Constraints
294
295Wallets may have governance policies:
296- **Whitelist**: Only transfers to pre-approved addresses allowed
297- **Spending Limit**: Max value per transaction (configured per wallet policy)
298
299Violations return HTTP 401 with an explanation message.
300
301## Important Notes
302
303- All POST requests require `Content-Type: application/json`
304- EVM token transfers require ETH in the wallet for gas fees
305- Solana token transfers require SOL in the wallet for fees
306- Solana transfer memos are optional and Solana-only: max 5 words, max 256 UTF-8 bytes, no control/invisible characters
307- Solana native transfers account for network fee and can auto-adjust requested transfer amount
308- 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)
309- If requested native SOL + platform fee + network fee cannot fit wallet balance, API returns `400 insufficient_balance`
310- Swap supports EVM (Uniswap) and Solana mainnet (Jupiter); Quote supports EVM and Solana mainnet; Approve is EVM-only
311- A platform fee (default 1%) is deducted from the token amount
312- Use `amount` for simplicity, use `value` for precise base-unit control
313- For robust agent behavior:
314 - First call `wallets`, then `wallet` (or `token-balance`), then `quote`, then `swap`.
315 - On 400 with `insufficient_token_balance`, reduce amount or change token.
316- The `.env` file in this skill folder stores your API key — never commit it to version control
317
318## File Structure
319
320```
321agentwalletapi/
322├── SKILL.md # This file
323├── .env # Your API key (created by setup.sh)
324├── scripts/
325│ ├── setup.sh # Creates .env with API key placeholder
326│ └── agentwalletapi.sh # CLI tool for making API calls
327└── references/
328 └── api-endpoints.md # Full endpoint documentation
329```
330
331See [references/api-endpoints.md](references/api-endpoints.md) for full endpoint details with request/response examples.