crypto-com-app
Original:🇺🇸 English
Translated
5 scripts
Execute crypto trades (buy, sell, swap, exchange) and query account balances, market prices, and transaction history via the Crypto.com APP API. View weekly trading limits and portfolio positions. Use when the user wants to trade, purchase, sell, or swap cryptocurrency, check token prices or portfolio balances, view recent trades, discover coins, or activate the kill switch. Supports BTC, ETH, CRO, and 200+ tokens across fiat and crypto wallets.
2installs
Added on
NPX Install
npx skill4agent add crypto-com/crypto-agent-trading crypto-com-appTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Skill: crypto-com-app
Agent Capability Requirements
This skill requires your agent platform to support the following capabilities. If your platform lacks any required capability, the skill will not function.
| Capability | Required | Details |
|---|---|---|
| Shell command execution | Yes | Must be able to run |
| Environment variables | Yes | Must read |
| JSON parsing | Yes | Must parse structured JSON from script stdout to extract fields |
| Multi-turn conversation | Yes | Trading uses a quote → confirm flow that spans multiple user turns |
| Persistent memory | No | Used for |
| Elapsed-time awareness | No | Used to check quote expiry ( |
CRITICAL: How This Skill Works
You MUST use the TypeScript scripts for ALL API interactions. NEVER call the API directly with , , or any other HTTP method.
curlfetchThe scripts handle request signing, error handling, and response formatting. If you bypass them:
- The request will fail (missing HMAC signature)
- The response won't be filtered or structured
For every user request, find the matching command below and run it via . Read the JSON output. Act on it.
npx tsxConfigurations
- BASE_URL:
https://wapi.crypto.com - CDC_API_KEY:
{{env.CDC_API_KEY}} - CDC_API_SECRET:
{{env.CDC_API_SECRET}} - CONFIRMATION_REQUIRED: (Default: true)
{{memory.confirmation_required}} - SKILL_DIR: The directory containing this file. Resolve it from the path you loaded this file from (e.g. if you read
SKILL.md, then/home/user/skills/crypto-com-app/SKILL.mdisSKILL_DIR)./home/user/skills/crypto-com-app
Environment Setup
-
Bothand
CDC_API_KEYmust be set as environment variables before use.CDC_API_SECRET -
Before running any script, check whether both variables are set by running:bash
echo "CDC_API_KEY=${CDC_API_KEY:+set}" "CDC_API_SECRET=${CDC_API_SECRET:+set}"If either prints empty instead of, prompt the user:set"Your API credentials are not configured. Please set them in your terminal before I can proceed:export CDC_API_KEY="your-api-key" export CDC_API_SECRET="your-api-secret"You can generate an API key at https://help.crypto.com/en/articles/13843786-api-key-management. Let me know once you've set them."Then stop and wait for the user to confirm before retrying. -
If a script returns aerror, treat it the same way: prompt the user to set the variables and wait.
MISSING_ENV
Script Commands
ALL API interactions MUST go through these scripts. They handle signing, execution, filtering, and error formatting. Run the appropriate command below via shell, then parse the JSON output.
Prerequisite: (Node.js 18+ required; is fetched automatically by ).
npx tsxtsxnpxImportant: All script paths below use as a placeholder for this skill's root directory. Resolve it from the path you loaded this SKILL.md from, or into the skill directory and use as the path. Either approach works.
$SKILL_DIRcd./scripts/...Account Commands
bash
# Filtered non-zero balances (scope: fiat | crypto | all)
npx tsx $SKILL_DIR/scripts/account.ts balances [fiat|crypto|all]
# Single token balance lookup
npx tsx $SKILL_DIR/scripts/account.ts balance <SYMBOL>
# Weekly trading limit
npx tsx $SKILL_DIR/scripts/account.ts trading-limit
# Find funded source wallets for a trade type
npx tsx $SKILL_DIR/scripts/account.ts resolve-source <purchase|sale|exchange>
# Kill switch — revoke API key
npx tsx $SKILL_DIR/scripts/account.ts revoke-keyTrade Commands
Trading follows a two-step flow: get a quotation first, then confirm the order.
bash
# Step 1 — Get quotation (type: purchase | sale | exchange)
npx tsx $SKILL_DIR/scripts/trade.ts quote <type> '<json-params>'
# Returns: {"ok": true, "data": {"id": "<quotation-id>", "from_amount": {...}, "to_amount": {...}, "countdown": 15, ...}}
# Step 2 — Confirm order: pass the data.id from Step 1 as <quotation-id>
npx tsx $SKILL_DIR/scripts/trade.ts confirm <type> <quotation-id>
# View recent transactions
npx tsx $SKILL_DIR/scripts/trade.ts historyHow to map user intent to trade type:
| User says | Trade type | From | To |
|---|---|---|---|
| "Buy CRO with 100 USD" | | USD (fiat) | CRO (crypto) |
| "Sell 0.1 BTC" | | BTC (crypto) | USD (fiat) |
| "Swap 0.1 BTC to ETH" | | BTC (crypto) | ETH (crypto) |
Quotation JSON params by trade type:
| Type | JSON fields |
|---|---|
| purchase | |
| sale | |
| exchange | |
Example — "Buy CRO with 100 USD":
- Run:
npx tsx $SKILL_DIR/scripts/trade.ts quote purchase '{"from_currency":"USD","to_currency":"CRO","from_amount":"100"}' - Read ,
data.id,data.from_amount,data.to_amountfrom the response.data.countdown - If confirmation required (default): Ask user "Confirm: 100 USD for X CRO? Valid for {countdown}s. Reply 'YES' to proceed."
- If user says YES (within countdown):
npx tsx $SKILL_DIR/scripts/trade.ts confirm purchase <data.id>
- If user says YES (within countdown):
- If confirmation opted out (is
memory.confirmation_required): Skip asking and immediately runfalsenpx tsx $SKILL_DIR/scripts/trade.ts confirm purchase <data.id>
Opt-in / Opt-out: Users can say "stop asking for confirmation" to auto-execute trades, or "require confirmation" to re-enable the prompt. See Section 3 below.
Coin Discovery Commands
bash
# Search coins
npx tsx $SKILL_DIR/scripts/coins.ts search '{"keyword":"BTC","sort_by":"rank","sort_direction":"asc","native_currency":"USD","page_size":10}'Required JSON parameters:
| Parameter | Type | Allowed values |
|---|---|---|
| string | |
| string | |
| string | Uppercase currency code (e.g. |
| string | Search string, 1–100 chars; matches coin name and symbol only |
| integer | Number of results per page |
Optional: — opaque token for fetching the next page (see pagination below).
page_tokenPagination: The response includes a object with (boolean) and (string). When is , pass as in the next request to fetch the next page.
paginationhas_morenext_page_tokenhas_moretruenext_page_tokenpage_tokenKey response fields per coin: (identical to / in trade and account APIs — use this to cross-reference), , , (price performance over past timeframes, e.g. ).
rails_idcurrency_idcurrencyprice_nativeprice_usdpercent_change_*_nativepercent_change_24h_nativeOutput Format
Every script prints structured JSON to stdout:
Success:
json
{"ok": true, "data": { ... }}Error:
json
{"ok": false, "error": "ERROR_CODE", "error_message": "Human-readable message"}Constraints
- Validation: Success requires in the script output.
ok: true - Confirmation Window: Quote validity is defined by the field in the quotation data.
countdown - Execution Warning: If order confirmation takes > 5s, notify: "Order submitted but taking longer than expected. Check order status with 'Show recent trades'".
- Rate Limits:
- Max 10 trades per minute.
- Max 100 API calls per minute.
- On HTTP 429 (error): wait 60 seconds before retrying the same request. Inform the user: "Rate limit reached — please wait 60 seconds before trying again."
RATE_LIMITED
Error Handling
All scripts return structured errors. Parse the field to determine the appropriate response.
errorScript Error Codes
These are the values in the script's JSON output. They tell you what category of failure occurred.
error| Error Code | Meaning | Agent Response |
|---|---|---|
| | Tell user to set env vars via terminal |
| API returned non-200 or | Report: "Transaction failed: {error_message}" |
| Bad command-line arguments | Show correct usage from the |
| Quotation request rejected by API | Report the |
| Order confirmation failed | Report and suggest: "Check order status with 'Show recent trades'" |
| Key already revoked or does not exist | "API key not found — it may have already been revoked." |
| Too many requests (HTTP 429) | "Rate limit reached — please wait 60 seconds before trying again." |
| Unexpected error | Report the raw |
Rule: When is in the output, stop the current operation and report the error to the user using the guidance above. Never proceed to the next step after a failure.
okfalseCommon API Errors (Quick Reference)
These are the specific API error codes that appear inside the of , , or responses. They tell you why the API rejected the request.
error_messageQUOTATION_FAILEDEXECUTION_FAILEDAPI_ERROR | Meaning | Recovery |
|---|---|---|
| Insufficient funds | Check balances, reduce trade amount |
| Currency code not recognized | Verify via coin search |
| Quote expired or already used | Request a new quotation |
| Quotation engine error | Retry shortly |
| Not eligible for Prime benefits | Proceed without Prime |
| Account not approved for trading | Contact support |
| Feature restricted on account | Report |
| An existing order is in progress | Wait or cancel existing order |
| Fiat-to-crypto not enabled | Account feature not available |
| Crypto-to-fiat not enabled | Account feature not available |
| Bank transfer not enabled | Account feature not available |
| Required parameter missing | Script bug — report it |
| Transaction creation failed | Retry or contact support |
| API key revoked or expired | Generate a new API key, update env vars |
| Key doesn't exist or belongs to another user | Verify correct key is set in |
For dynamic errors (limit exceeded, currency disabled, cooling-off, etc.), report the and directly to the user. For full details, see references/errors.md.
errorerror_messageLogic & Rules
1. Asset & Source Disambiguation
Determine the trade type first:
- Purchase — fiat → crypto
- Sale — crypto → fiat
- Exchange — crypto → crypto
Then resolve the source wallet:
- For purchase: run . The script returns only funded fiat entries.
npx tsx $SKILL_DIR/scripts/account.ts resolve-source purchase - For sale or exchange: run (or
npx tsx $SKILL_DIR/scripts/account.ts resolve-source sale). The script returns only funded crypto entries.exchange
Result (from ):
data.status- → auto-select
SELECTED.data.currency - → prompt user to choose from
AMBIGUOUS.data.options - → inform user "No funded wallets found" and stop.
EMPTY
"Sell All" Scenario: If user says "Sell all [TOKEN]", run . Use the amount (or ) as for the quotation.
npx tsx $SKILL_DIR/scripts/account.ts balance [TOKEN]data.availabledata.balancefrom_amount2. Trading Process (Quotation → Confirmation → Execution)
When the user asks to buy, sell, or swap crypto, always follow this three-step flow:
-
Step A — Get Quotation: Build the JSON params from the user's request (see the "Quotation JSON params" table in Trade Commands) and run:Read
npx tsx $SKILL_DIR/scripts/trade.ts quote <type> '<json-params>',data.id,data.from_amount, anddata.to_amountfrom the response.data.countdown -
Step B — Ask User to Confirm:
- IF is
memory.confirmation_required(or unset):true- Prompt: "Confirm: {from_amount} for {to_amount}? Valid for {countdown}s. Reply 'YES' to proceed."
- Expiration Logic: If the user replies "YES" after seconds have elapsed, reject: "Transaction rejected: The quotation rate has expired. Please request a new quote."
countdown - Execute Step C ONLY if user replies "YES" within the valid window.
- ELSE (Opted Out):
- Notify: "Quotation received. Proceeding to execution automatically..."
- Immediately proceed to Step C.
- IF
-
Step C — Execute Order: Run:using the
npx tsx $SKILL_DIR/scripts/trade.ts confirm <type> <data.id>from Step A.id
3. Memory Management (Opt-in/Out)
- To Opt-out: If user says "stop asking for confirmation" or "enable auto-trade", update to
memory.confirmation_required.false - To Opt-in: If user says "require confirmation" or "enable manual trade", update to
memory.confirmation_required.true - Platforms without persistent memory: If your platform does not support , treat
{{memory.*}}as alwaysconfirmation_required(safest default).true
4. Error Handling
- All script outputs include an field. Success is defined ONLY as
ok.ok: true - If is
ok, readfalseand respond per the Error Handling table above.error - Never proceed to the next step after a failed command.
5. Account & History
- History: Run — display the entries from
npx tsx $SKILL_DIR/scripts/trade.ts history.data - Weekly Trading Limit: Run — display as: "📊 Weekly Trading Limit: {data.used} / {data.limit} USD (Remaining: {data.remaining} USD)".
npx tsx $SKILL_DIR/scripts/account.ts trading-limit - Balances (Categorized):
- If "List Fiat": run .
npx tsx $SKILL_DIR/scripts/account.ts balances fiat - If "List Crypto": run .
npx tsx $SKILL_DIR/scripts/account.ts balances crypto - If "List All": run . Crucial: Display Fiat category first, followed by Crypto balances below.
npx tsx $SKILL_DIR/scripts/account.ts balances all - The scripts automatically filter out zero-balance entries. If a category has no entries in the output, display "No holdings" under that header.
- If "List Fiat": run
6. Kill Switch
- Trigger: User says "STOP ALL TRADING", "kill switch", or similar emergency stop command.
- ALWAYS require explicit confirmation regardless of :
memory.confirmation_required- Prompt: "⚠️ WARNING: This will immediately revoke your API key and disable all trading. A new API key must be generated to resume. Type 'CONFIRM KILL SWITCH' to proceed."
- Execute ONLY if user replies with the exact phrase.
- Execution: Run .
npx tsx $SKILL_DIR/scripts/account.ts revoke-key - On success (): Notify: "🛑 Kill switch activated. API key has been revoked. All trading is disabled. Generate a new API key and update your environment variables to resume."
ok: true - On error: Notify: "API key not found — it may have already been revoked or does not exist."
API_KEY_NOT_FOUND - Idempotency: Revoking an already-revoked key is not an error; treat it the same as a successful revocation.
7. Balance Display Format
- Fiat Header: "🏦 Fiat Balances"
- Crypto Header: "🪙 Crypto Balances"
- Always list Fiat section before Crypto section when both are requested.
- Never display zero-balance assets. Only show assets with a balance greater than 0. If all assets in a category are zero, show "No holdings" under that header.