← Back to Plugins
Tools

Clawdexter

BranchManager69 By BranchManager69 👁 19 views ▲ 0 votes

Moltbot plugin for Dexter x402 - 59+ Solana DeFi tools via MCP

GitHub

Configuration Example

{
  "plugins": {
    "dexter-x402": {
      "svmPrivateKey": "YOUR_SOLANA_PRIVATE_KEY",
      "evmPrivateKey": "0xYOUR_EVM_PRIVATE_KEY",
      "maxPaymentUSDC": "0.50"
    }
  }
}

README

# Dexter x402 Plugin for Moltbot

The most comprehensive x402 payment plugin for Moltbot. Provides:

1. **Generic x402 Payments** (`x402_pay`) - Call ANY x402-enabled paid API with automatic USDC payment
2. **x402 Directory Search** (`x402_search`) - Discover paid APIs across multiple networks
3. **59+ Dexter DeFi Tools** (`dexter_x402`) - Authenticated access to Dexter's MCP tools

## Overview

### Generic x402 Tools (No Auth Required)

Configure your wallet keys and start making paid API calls immediately:

- **`x402_pay`** - Make paid requests to any x402 endpoint (Solana, Base, Polygon, Arbitrum, Optimism, Avalanche)
- **`x402_search`** - Search the aggregated directory of 2600+ paid APIs

### Dexter MCP Tools (OAuth Required)

Connect to Dexter's 59+ Solana DeFi tools via OAuth:

- **`dexter_x402`** - Gateway to wallet management, trading, analytics, games, and more

## Quick Start

### Option A: Generic x402 (No Auth - Config Only)

Add your wallet keys to `~/.moltbot/moltbot.json`:

```json
{
  "plugins": {
    "dexter-x402": {
      "svmPrivateKey": "YOUR_SOLANA_PRIVATE_KEY",
      "evmPrivateKey": "0xYOUR_EVM_PRIVATE_KEY",
      "maxPaymentUSDC": "0.50"
    }
  }
}
```

Then use:
```bash
# Search for paid APIs
moltbot agent -m "Use x402_search to find weather APIs"

# Call a paid endpoint
moltbot agent -m "Use x402_pay to call https://example.com/api/data"
```

### Option B: Dexter Tools (OAuth Required)

#### 1. Authenticate

```bash
moltbot models auth login --provider dexter-x402
```

This opens OAuth flow in your browser. Sign in with your Dexter account and authorize Moltbot.

### 2. Use Tools

The plugin exposes a single gateway tool `dexter_x402` that provides access to all 59+ Dexter capabilities:

```bash
# List available tools
moltbot agent --local --session-id demo -m "Use dexter_x402 with action='list'"

# Call a specific tool
moltbot agent --local --session-id demo -m "Use dexter_x402 to check trending Solana tokens"
```

Or simply ask naturally:

```bash
moltbot agent --local --session-id demo -m "What's trending on Solana right now?"
```

## Available Tools (59+)

### ๐Ÿ’ผ Wallet Management
| Tool | Description |
|------|-------------|
| `resolve_wallet` | Resolve the effective managed wallet for this session |
| `list_my_wallets` | List all wallets linked to your Dexter account |
| `set_session_wallet_override` | Override wallet for the current session |
| `auth_info` | Diagnostics for wallet resolution and token state |

### ๐Ÿ’ฑ Solana Trading
| Tool | Description |
|------|-------------|
| `solana_resolve_token` | Resolve token metadata by name, ticker, or address |
| `solana_send` | Transfer SOL, USDC, DEXTER, PAYAI, or any SPL token |
| `solana_swap_preview` | Preview a token swap before execution |
| `solana_swap_execute` | Execute a previewed swap |
| `jupiter_quote_preview` | Get Jupiter DEX swap quote |
| `jupiter_quote_pro` | Jupiter quote with pro-tier features |

### ๐Ÿ“Š Analytics & Research
| Tool | Description |
|------|-------------|
| `search` | Web search with real-time results |
| `fetch` | Retrieve and summarize web pages |
| `pumpstream_live_summary` | Live pump.fun stream analytics |
| `markets_fetch_ohlcv` | Birdeye OHLCV candle data |
| `onchain_activity_overview` | On-chain analytics for tokens/wallets |
| `onchain_entity_insight` | Deep analysis of wallets, tokens, or signatures |
| `solscan_trending_tokens` | Solscan trending tokens snapshot |
| `slippage_sentinel` | Volatility analysis & optimal slippage calculation |
| `twitter_topic_analysis` | Twitter sentiment and conversation analysis |

### ๐ŸŽฌ Creative & Media (x402 Paid)
| Tool | Description |
|------|-------------|
| `sora_video_job` | Generate video clips with OpenAI Sora |
| `meme_generator_job` | AI-powered meme and image generation |
| `studio_breaking_news` | Create newscast videos and infographics |
| `studio_news_status` | Check breaking news job status |

### ๐ŸŽฎ Games
| Tool | Description |
|------|-------------|
| `pokedexter_create_challenge` | Create wagered Pokรฉmon battle ($1-$25) |
| `pokedexter_accept_challenge` | Accept a battle challenge |
| `pokedexter_make_move` | Submit battle action |
| `pokedexter_get_battle_state` | Get current battle state |
| `pokedexter_join_queue` | Join quick match queue |
| `games_king_usurp` | Become King of Dexter ($0.01) |
| `games_king_state` | View current King state |
| `games_story_append` | Add to the Infinite Story ($0.01) |
| `games_story_read` | Read the Infinite Story |

### ๐Ÿš€ Hyperliquid (Perpetuals)
| Tool | Description |
|------|-------------|
| `hyperliquid_markets` | List tradable perp symbols |
| `hyperliquid_opt_in` | Provision agent wallet for perp trading |
| `hyperliquid_fund` | Bridge SOL โ†’ USDC โ†’ Hyperliquid |
| `hyperliquid_bridge_deposit` | Deposit from Arbitrum |
| `hyperliquid_perp_trade` | Submit perpetual orders |

### ๐Ÿ”ง Codex Sessions
| Tool | Description |
|------|-------------|
| `codex_start` | Begin a new Codex conversation |
| `codex_reply` | Follow-up to existing Codex session |
| `codex_exec` | Run Codex with optional JSON schema |

### ๐Ÿญ Studio (Superadmin)
| Tool | Description |
|------|-------------|
| `studio_create` | Start a Studio agent task |
| `studio_status` | Check job status |
| `studio_cancel` | Cancel running job |
| `studio_inspect` | Full job details |
| `studio_list` | List recent jobs |

### ๐Ÿ“บ Stream Engagement
| Tool | Description |
|------|-------------|
| `stream_public_shout` | Submit shout-out for live stream |
| `stream_shout_feed` | Get latest public shouts |

## Architecture

```
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     OAuth 2.0 + PKCE      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚    Moltbot      โ”‚โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บโ”‚  Dexter OAuth    โ”‚
โ”‚  (dexter-x402    โ”‚                           โ”‚  (dexter-api)    โ”‚
โ”‚    plugin)      โ”‚                           โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚
         โ”‚  MCP Protocol (JSON-RPC over HTTP)
         โ”‚  - tools/list
         โ”‚  - tools/call
         โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     Internal      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Dexter x402    โ”‚โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บโ”‚  Dexter Backend  โ”‚
โ”‚    Server       โ”‚                   โ”‚  (59+ tools)     โ”‚
โ”‚ mcp.dexter.cash โ”‚                   โ”‚                  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
```

### Authentication Flow

**Primary (Desktop/CLI):**
1. **Link Request**: Plugin creates a tracking code via `api.dexter.cash/api/moltbot/link/create`
2. **DCR**: Plugin registers with Dexter's OAuth server using remote callback (`dexter.cash/moltbot/link/callback`)
3. **PKCE Authorization**: Browser-based OAuth with S256 code challenge
4. **Remote Callback**: OAuth redirects to `dexter.cash`, backend stores tokens
5. **Poll Completion**: Plugin polls for tokens, retrieves them when ready
6. **Automatic Refresh**: Tokens refreshed automatically before expiry

**Fallback (Telegram/Remote):**
1. **Device Code**: Plugin creates link code, displays to user
2. **Manual Auth**: User visits `dexter.cash/moltbot/link?code=XXXX`, signs in
3. **Poll Completion**: Plugin polls until user completes auth

### MCP Integration

The plugin uses the official `@modelcontextprotocol/sdk` to:

1. Establish `StreamableHTTPClientTransport` connection to `mcp.dexter.cash/mcp`
2. Send `tools/list` JSON-RPC requests to discover available tools
3. Execute `tools/call` JSON-RPC requests for tool invocation
4. Handle response content (text, JSON, images)

## Configuration

Full configuration in `~/.moltbot/moltbot.json`:

```json
{
  "plugins": {
    "dexter-x402": {
      "svmPrivateKey": "base58_solana_private_key",
      "evmPrivateKey": "0x_hex_evm_private_key",
      "defaultNetwork": "solana",
      "maxPaymentUSDC": "0.50",
      "baseUrl": "https://mcp.dexter.cash/mcp",
      "directoryUrl": "https://api.dexter.cash/api/x402/directory",
      "autoRefreshTools": true,
      "disableTelemetry": false
    }
  }
}
```

### Config Options

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `svmPrivateKey` | string | - | Solana private key (base58) for x402 payments |
| `evmPrivateKey` | string | - | EVM private key (hex) for Base/Polygon/etc payments |
| `defaultNetwork` | string | `"solana"` | Preferred network: solana, base, polygon, arbitrum, optimism, avalanche |
| `maxPaymentUSDC` | string | `"0.50"` | Maximum payment per request (e.g., "0.50" = $0.50) |
| `baseUrl` | string | `https://mcp.dexter.cash/mcp` | Dexter MCP server (for authenticated tools) |
| `directoryUrl` | string | `https://x402.dexter.cash/api/x402/directory` | x402 directory API |
| `autoRefreshTools` | boolean | `true` | Refresh Dexter tool list on connection |
| `disableTelemetry` | boolean | `false` | Disable anonymous usage telemetry |

## Tools Reference

### x402_pay (Generic Payments)

Call ANY x402-enabled paid API with automatic USDC payment. No authentication required - just configure wallet keys.

**Supported Networks:** Solana, Base, Polygon, Arbitrum, Optimism, Avalanche

**Parameters:**
| Param | Type | Required | Description |
|-------|------|----------|-------------|
| `url` | string | Yes | The x402-enabled endpoint URL |
| `method` | string | No | HTTP method (default: GET) |
| `params` | object | No | Query params (GET) or JSON body (POST) |
| `headers` | object | No | Custom HTTP headers |

**Example:**
```bash
moltbot agent -m "Use x402_pay to call https://x402.dexter.cash/api/onchain/activity/overview with params {\"entityId\": \"SOL\"}"
```

**How it works:**
1. Makes request to the URL
2. If 402 returned, SDK automatically signs USDC payment
3. Retries request with payment proof
4. Returns response data

### x402_search (Directory Search)

Search the aggregated directory of x402-enabled paid APIs. Combines Dexter's catalog with external sources.

**Parameters:**
| Param | Type | Required | Description |
|-------|------|----------|-------------|
| `query` | string | No | Search term (searches url, description) |
| `netw

... (truncated)
tools

Comments

Sign in to leave a comment

Loading comments...