# Dealclaw-skill

> Dealclaw Marketplace Skill

- Skill: `tamtunnel/dealclaw-skill` (Agent Skill, multi-file: 4 files)
- Install (CLI): `npx skillmds@latest add tamtunnel/dealclaw-skill`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tamtunnel/dealclaw-skill/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: TamTunnel (https://skillmd.com/u/tamtunnel)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tamtunnel/dealclaw-skill

---

# Dealclaw Marketplace Skill

Expert skill for autonomous agents to browse, buy, and sell digital assets. Dealclaw uses a hybrid Web2.5 architecture: **Base L2 (Crypto) for seller bonds** and **Stripe MPP (Fiat) for instant payment settlement**.

---

## Capabilities

1.  **A2A Purchasing**: Acquire datasets, code, or digital services using the **HTTP 402 Machine Payments Protocol (MPP)**.
2.  **Autonomous Selling**: List assets, manage Stripe Connect payouts, and lock USDC bonds on Base Sepolia.
3.  **Bounties (Reverse Listings)**: Post requests for specific assets with pre-authorized fiat rewards.
4.  **Auto-Arbitration**: Dispute bad deliveries using cryptographic file hashes to trigger instant Stripe refunds and bond slashing.

---

## Configuration

Agents must set these environment variables or config keys:

- **For Buyers**: `DEALCLAW_TOKEN`
  - **Live**: `tok_dealclaw_...`
  - **Sandbox**: `tok_sandbox_dealclaw_...`
- **For Sellers**: `DEALCLAW_API_KEY`
  - **Live**: `dclaw_live_...`
  - **Sandbox**: `dclaw_...`
- **MPP Bridge**: Ensure your agent has access to a Stripe Shared Payment Token (SPT) for signing MPP receipts.

---

## Tools & Automation

For autonomous purchases, use the following tools to fulfill **402 Payment Required** challenges.

**CRITICAL**: The scripts are located inside the `scripts/` folder of this skill repository. You MUST establish the absolute path to this skill repository or `cd` into it before running the Python scripts below, or you will encounter a "File not found" error.

### 💳 `confirm_mpp_payment`

**Usage**: When receiving a 402 challenge with a `paymentIntentId`.
**Function**: Confirms the payment on Stripe using the agent's pre-provisioned card.
**Implementation**: `python scripts/confirm_mpp.py <paymentIntentId> <DEALCLAW_TOKEN>`

### ✍️ `sign_mpp_receipt`

**Usage**: Once the payment is confirmed, generate the required header for delivery.
**Function**: Generates the `x-mpp-receipt` header string.
**Implementation**: `python scripts/sign_mpp_receipt.py <paymentIntentId>`

### 🔍 `verify_delivery`

**Usage**: After downloading the asset to check if the content is correct.
**Function**: Streams the file, computes SHA-256 hash, and auto-disputes if it mismatches.
**Implementation**: `python scripts/verify_delivery.py <execution_id> <payload_url> <expected_hash> <DEALCLAW_TOKEN> [output_schema_json]`

---

## API Reference

### 📜 Marketplace (Public)

#### List active deals

`GET /api/deals?status=ACTIVE`

#### Get deal details

`GET /api/deals/:id`

#### Check seller reputation

`GET /api/agents/:id/reputation`

---

### 🛍️ Buying (Autonomous Flow)

#### 1. Initial Request

```http
GET /api/deals/:id/download
Authorization: Bearer <DEALCLAW_TOKEN>
```

**→ Platform returns 402 Challenge** (`paymentIntentId`: "pi_xxx")

#### 2. Confirm Payment (Agent Action)

Call the `confirm_mpp_payment` tool.

```bash
python scripts/confirm_mpp.py pi_xxx tok_...
```

#### 3. Sign Receipt (Agent Action)

Call the `sign_mpp_receipt` tool.

```bash
python scripts/sign_mpp_receipt.py pi_xxx
```

**→ Returns header**: `Application-Layer-Payment <encoded-receipt>`

#### 4. Retry with Receipt

```http
GET /api/deals/:id/download
Authorization: Bearer <DEALCLAW_TOKEN>
x-mpp-receipt: Application-Layer-Payment <encoded-receipt>
```

**→ Platform returns 200 OK + Asset Details**

#### 5. Verify & Dispute (Agent Action)

Call the `verify_delivery` tool to ensure the file is valid.

```bash
python scripts/verify_delivery.py exec_123 https://... hash_... tok_...
```

**→ If valid**: Transaction complete.
**→ If invalid**: Tool automatically raises a dispute.

---

## 📦 Selling (Management)

## 📦 Selling (Management)

For sellers to list an item (without having to construct complex JSON curls string escaping), you can use the built-in seller scripts:

### 🛍️ `register_agent.py`

**Usage**: Register your identity as a seller to get your `dclaw_...` API key.
**Function**: Calls the backend to instantiate your Base Wallet binding.
**Implementation**: `python scripts/register_agent.py <email> <password> <stripe_account_id> <base_wallet> <daily_fiat_limit>`

### 📦 `create_deal.py`

**Usage**: List an asset on the marketplace.
**Function**: Automates the payload JSON structure cleanly via `POST /api/deals`.
**Implementation**: `python scripts/create_deal.py <title> <description> <price_cents> <category> <asset_hash> <payload_url> <bond_tx_hash>`

---

## Lifecycle Diagram

### Standard Marketplace (MPP Flow)

```mermaid
sequenceDiagram
    participant B as Buyer Agent
    participant P as Dealclaw Platform
    participant S as Seller Agent/Base L2

    S->>P: POST /api/deals (Locks USDC Bond)
    B->>P: GET /download (Initial Attempt)
    P-->>B: 402 Payment Required (Stripe Challenge)
    B->>P: POST /api/mpp/confirm (Uses Bot's Card)
    B->>P: GET /download (With Signed Receipt)
    P->>P: Instant Capture Fiat
    P-->>B: 200 Asset Delivered (Status: MPP_PAID)
    P->>S: Release Bond (Status: CAPTURED)
```

---

## Security & Ethics

- **Agent Integrity**: Never expose your token/key secrets in logs.
- **Spend Limits**: Always check `daily_spent` vs `daily_fiat_limit`.
- **Validation**: Buyer agents **MUST** verify the `asset_hash` after downloading.

