Skip to main content
Glama
README.md
# cmc-agent-dd โ€” token due diligence for AI agents, powered by CoinMarketCap

**Before an AI agent buys a token, accepts one as payment, or tells a human to ape in, it should ask one question: _is this token safe to touch?_**
`cmc-agent-dd` answers it in one call. Give it a chain and a contract address; it pulls CoinMarketCap market, DEX-security, liquidity and holder data and returns a **๐ŸŸข GREEN / ๐ŸŸก YELLOW / ๐Ÿ”ด RED** verdict with plain-language reasons โ€” and every number names the CMC endpoint it came from.

Built for **Build with CMC: API Hackathon (Round 2)** ยท Track: **AI Agents and Automation** ยท `#BuildwithCMC`

A real run โ€” an excerpt (some rows and reasons omitted) of [`docs/evidence/report-red-catme-bsc.md`](docs/evidence/report-red-catme-bsc.md); every line shown is verbatim:

```text
$ cmc-dd dd bsc 0xb71b42f7f0513b3f49a0a42ffdcf90509a888888
## ๐Ÿ”ด RED โ€” avoid CATME (ELON'S CAT): Security scan: A scam address may be associated with fraud, Ponzi schemes, or other malicious activities. Users should conduct extra verification before transactions.

- **Token:** CATME โ€” ELON'S CAT
- **Chain / contract:** BSC ยท `0xb71b42f7f0513b3f49a0a42ffdcf90509a888888`
- **Liquidity:** $16
- **Holders:** 164.9K
- **Taxes:** buy 0% / sell 0.56%

### Why
- ๐Ÿ”ด Security scan: A scam address may be associated with fraud, Ponzi schemes, or other malicious activities. Users should conduct extra verification before transactions.
- ๐Ÿ”ด CoinMarketCap marks this token's risk level as "highRisk".
- ๐Ÿ”ด Only $16 of DEX liquidity โ€” a small trade moves the price a lot and exits may be impossible.
- ๐ŸŸก Security scan: The token was deployed by a high-risk address, which may be associated with fraud, exploits, or other malicious activities.
- ๐ŸŸก Security scan: Low liquidity means that there is no or a small liquidity pool, resulting in failure to swap or large slippage.

### Data sources (CoinMarketCap API, 8 credits)
- `/v1/dex/holders/count` โ†’ HTTP 200 @ 2026-11-22T12:16:11.776Z
- `/v1/dex/liquidity-change/list` โ†’ HTTP 200 @ 2026-11-22T12:16:11.775Z
- `/v1/dex/security/detail` โ†’ HTTP 200 @ 2026-11-22T12:16:11.409Z
- `/v1/dex/token` โ†’ HTTP 200 @ 2026-11-22T12:16:11.788Z
- `/v1/global-metrics/quotes/latest` โ†’ HTTP 200 @ 2026-11-22T12:16:11.252Z
- โ€ฆ
```

**All real outputs, captured from the live API** (`npx tsx scripts/capture-evidence.ts` regenerates them):

| Verdict | Token | Why |
|---|---|---|
| ๐ŸŸข GREEN | [CAKE on BSC](docs/evidence/report-green-cake-bsc.md) | $11M liquidity, 1.89M holders, 120 exchanges, CMC rank #74 |
| ๐ŸŸข GREEN | [BONK on Solana](docs/evidence/report-green-bonk-solana.md) | Solana blue chip |
| ๐ŸŸก YELLOW | [USDC on Ethereum](docs/evidence/report-yellow-usdc-ethereum.md) | honest YELLOW: the contract can blacklist, pause, mint and be upgraded |
| ๐ŸŸก YELLOW | [the original AERO contract on Base](docs/evidence/report-yellow-aero-legacy-base.md) | CoinMarketCap's AERO now lives at a different contract; this one has a long history, so it's flagged as a likely legacy version, not a fake |
| ๐Ÿ”ด RED | [CATME on BSC](docs/evidence/report-red-catme-bsc.md) | scam-flagged by the security scan, CMC "highRisk", $16 liquidity |
| ๐Ÿ”ด RED | [BNBCake on BSC](docs/evidence/report-red-bnbcake-bsc.md) | reported by users / researchers, $4.6K liquidity |

Plus the [raw CMC responses](docs/evidence/raw-cmc-responses.json) behind a report, a [market pulse](docs/evidence/market-pulse.json), and a [real pay-per-request x402 call](docs/evidence/x402-call.json) (402 โ†’ signed USDC authorization โ†’ 200).

## Three ways to use it

| | For | How |
|---|---|---|
| **MCP server** | Claude Desktop, Cursor, OpenClaw, any MCP client | tools `token_due_diligence`, `market_pulse`, `search_token` |
| **CLI** | humans, scripts, CI | `cmc-dd dd <chain> <address>` ยท `cmc-dd pulse` |
| **Paid agent on BotHire** | other AI agents | hire it on [BotHire](https://www.bothire.io), pay into on-chain escrow, send `{chain, address}`, get the report |

**This ran for real** ([`docs/evidence/bothire-agent-hire.json`](docs/evidence/bothire-agent-hire.json)): a human-backed buyer agent hired the [*CMC Due Diligence Desk*](https://www.bothire.io/skill/ff1a4110-8b26-4ec4-bb22-0fd4727caa22) on BotHire, deposited **1 USDC into escrow on Arc mainnet** ([deposit](https://explorer.arc.io/tx/0x64e275670db877067baf135d2c317ebed75bb6003f170b69e41b747b89d25919)), asked about a BSC token; this repo's `src/provider.ts` built the CoinMarketCap report (๐Ÿ”ด RED โ€” scam-flagged) and delivered it; the escrow settled for one report ([settle](https://explorer.arc.io/tx/0x8abd25b87d21464fd6348e65a272f416bab9b3f297390d187447d15cdc7e3e64)); and the buyer recomputed the report's `result_hash` and got the same value.

The third one is the point: CMC data becomes a **service one agent sells to another**. A buyer agent pays a small USDC fee into escrow on BotHire; `src/provider.ts` runs the due diligence on CoinMarketCap data and delivers the report; the escrow pays out. No human in the loop on either side.

## CMC API endpoints used

| Endpoint | Used for |
|---|---|
| `/v1/dex/token` | price, liquidity, age, 24h trades, owner, CMC risk level (`rl`), CMC asset id (`cid`), CEX listings |
| `/v1/dex/security/detail` | honeypot / rug / fake-token status, buy & sell tax, verification, vendor flags, user reports, scan items |
| `/v1/dex/holders/count` | holder count |
| `/v1/dex/liquidity-change/list` | liquidity add/remove events (rug-pull signal) |
| `/v3/cryptocurrency/quotes/latest` | CMC listing & rank, CMC market cap, look-alike / impersonation check |
| `/v3/fear-and-greed/latest` ยท `/v1/altcoin-season-index/latest` ยท `/v1/global-metrics/quotes/latest` ยท `/v3/index/cmc20-latest` | market context and `market_pulse` |
| `/v1/dex/platform/list` | chain names โ†’ CMC platforms |
| `/v1/dex/search` | `search_token` (find the right contract) |
| `/x402/โ€ฆ` | pay-per-request mode (quotes, listings, DEX search) |

## What it checks

| Signal | Red ๐Ÿ”ด | Yellow ๐ŸŸก |
|---|---|---|
| Security scan: honeypot / rug-pull / fake token (EVM and Solana), vendor flag, user reports | any hit | โ€” |
| Security scan items (CMC risk level `r` / `y`) | `r` items (e.g. "scam address") | `y` items (e.g. blacklist, mintable, upgradeable) |
| Buy / sell tax | โ‰ฅ 10% | 3โ€“10% |
| Contract source | โ€” | not verified |
| DEX liquidity | < $10K | < $100K |
| Liquidity pulled (add/remove events, last 24h) | one tx removed โ‰ฅ 50% of what's left | net outflow โ‰ฅ 30% |
| CoinMarketCap risk level (`rl`) | high | other non-"safe" levels |
| **Look-alike / impersonation** โ€” this contract is not a CMC asset, but a ranked CMC asset uses its symbol (symbols normalized, so `$USDC` / `USDC.e` can't dodge it) | that asset is in the top 500 and this contract is young / little-held | ranked lower, or this contract is long-established (legacy / migrated) |
| Holders ยท age ยท 24h move ยท volume vs liquidity | โ€” | < 500 ยท < 7 days ยท ยฑ50% ยท โ‰ฅ 10ร— |
| Market cap โ‰ซ liquidity | โ€” | market cap > 100,000ร— liquidity is flagged as meaningless |
| No security scan **and** no CMC listing | โ€” | "unchecked" |
| Contract owner, no scan on a listed asset, low CMC rank | info | |
| Deep liquidity, many holders, CMC top-1000, CEX listings, age, CMC "safe" (CMC's label is shown only when nothing is red) | good signs โ€” never override a flag | |

Rules that keep it honest:
- If CoinMarketCap can't be reached for the core token data (rate limit, auth, outage), **no verdict is issued** โ€” an error is returned instead of a misleading GREEN.
- A contract CMC knows nothing about is YELLOW ("check the address and chain"), never GREEN; if the look-alike lookup or the liquidity-events lookup fails, that is a YELLOW too.
- Token names and symbols come from whoever deployed the contract, so they are stripped of Markdown/control characters before they appear in a report.

Thresholds live in one object (`RULES` in [`src/dd.ts`](src/dd.ts)). The scoring step (`assess`) is a pure function; [34 tests](test/) cover it, the client and the x402 payer. Every report carries `sources` (endpoint, HTTP status, CMC timestamp, credits), `credits_used` and a `result_hash` (sha256 of the canonical report) so a buyer can prove what it was sold.

## Quick start

```bash
git clone https://github.com/BotHireAgent/cmc-agent-dd && cd cmc-agent-dd
npm install                     # also builds dist/ (prepare script)
npm run dd -- bsc 0x0E09FaBB73Bd3Ade0a17ECc321fD13a19e81cE82    # works with no key (keyless API, low rate limit)
export CMC_API_KEY=your-own-key # recommended: https://coinmarketcap.com/api (never commit it)
npm run pulse
npm test
```

### Three ways to call CMC

`src/cmc.ts` picks the mode automatically:

1. **`CMC_API_KEY` set** โ†’ the Pro API with your key. Recommended.
2. **No key** โ†’ CMC's **keyless public API** โ€” the whole pipeline runs, at a low anonymous rate limit. Good for trying it.
3. **No key + `CMC_X402_PRIVATE_KEY`** โ†’ **pay per request with x402** for the endpoints CMC sells that way (quotes, listings, DEX search, DEX pair quotes), keyless for the rest. CMC answers `402 Payment Required`; the client signs an EIP-3009 USDC authorization on Base with the agent's own wallet and retries โ€” $0.01 per call, no account. Guard rails: Base USDC only, fixed EIP-712 domain, per-call ceiling (`CMC_X402_MAX_USDC`, default 0.05), per-process cap (`CMC_X402_MAX_TOTAL_USDC`, default 1), optional payee pin (`CMC_X402_PAYTO`), redirects refused. See [`src/x402.ts`](src/x402.ts) and the [captured call](docs/evidence/x402-call.json).

### MCP (Claude Desktop / Cursor / OpenClaw)

```json
{
  "mcpServers": {
    "cmc-dd": { "command": "node", "args": ["/path/to/cmc-agent-dd/dist/mcp.js"], "env": { "CMC_API_KEY": "your-key" } }
  }
}
```

Then ask: _"Is 0xโ€ฆ on BSC safe to buy?"_ โ€” the agent calls `token_due_diligence`. Ask _"find the real PEPE on Ethereum"_ and it uses `search_token` first.

### Sell it on BotHire

```bash
export CMC_API_KEY=... BOTHIRE_API_KEY=bh_... BOTHIRE_BOT_ID=...
npm run provider          # polls paid hires, answers each {chain, address} request with a report
```

Register the agent and list the skill per [bothire.io/skill.md](https://www.bothire.io/skill.md). The worker is built for paid work: each request is written (fsync'd) to a local queue before anything else, a report is built once and stored so retries never pay CMC twice, deliveries BotHire permanently refuses are not retried forever, metered-escrow hires are settled once with the number of reports actually delivered, and a damaged state file stops the worker instead of silently dropping paid jobs.

## Project layout

```
src/cmc.ts        CMC client: key / keyless / x402 modes, per-call provenance (the key is never recorded)
src/x402.ts       x402 v2 payer (EIP-3009 on Base USDC) with price ceiling, spend cap and optional payee pin
src/chains.ts     chain alias โ†’ CMC DEX platform (via /v1/dex/platform/list)
src/dd.ts         due-diligence pipeline + pure scoring (assess) + canonical hash
src/pulse.ts      market pulse
src/format.ts     Markdown report
src/mcp.ts        MCP server (stdio)
src/cli.ts        CLI
src/provider.ts   BotHire seller agent
scripts/          evidence capture (reports, raw responses, x402 call)
docs/API_FEEDBACK.md   what the CMC API made possible, and where it got in the way
docs/evidence/    real CMC responses and reports (no keys)
```

## Disclaimer

An automated screen of CoinMarketCap data, not financial advice. GREEN means no flags were found, not that a token is safe.

MIT ยฉ BotHire