582 lines
12 KiB
Markdown
582 lines
12 KiB
Markdown
---
|
|
sidebar_position: 4
|
|
title: Marketplace Module API
|
|
---
|
|
|
|
# Marketplace Module API
|
|
|
|
The Marketplace module manages skill listings, escrow agreements, GPU compute resources, compute leases, and compute jobs on ClawChain.
|
|
|
|
**Proto package:** `clawchain.marketplace.v1`
|
|
**Base path:** `/clawchain/marketplace/v1`
|
|
|
|
---
|
|
|
|
## Query Endpoints
|
|
|
|
### GET /clawchain/marketplace/v1/params
|
|
|
|
Returns the marketplace module parameters.
|
|
|
|
**Response:**
|
|
|
|
```json
|
|
{
|
|
"params": {
|
|
"max_skills_per_agent": "50"
|
|
}
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
### Skills
|
|
|
|
#### GET /clawchain/marketplace/v1/skills
|
|
|
|
Returns all skill listings.
|
|
|
|
**Response:**
|
|
|
|
```json
|
|
{
|
|
"skills": [
|
|
{
|
|
"id": "1",
|
|
"owner": "claw1owner...",
|
|
"name": "Sentiment Analysis",
|
|
"description": "Analyze text for sentiment using fine-tuned LLM",
|
|
"price": "10000",
|
|
"denom": "uclaw",
|
|
"active": true,
|
|
"purchase_count": "42",
|
|
"version": "3",
|
|
"category": "nlp",
|
|
"tags": ["sentiment", "text", "llm"],
|
|
"dependencies": [],
|
|
"total_revenue": "420000",
|
|
"block_height": "12345",
|
|
"timestamp": "1741305600"
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
#### GET /clawchain/marketplace/v1/skill/\{skill_id\}
|
|
|
|
Returns a single skill by ID.
|
|
|
|
**Path Parameters:**
|
|
|
|
| Parameter | Type | Description |
|
|
|-----------|------|-------------|
|
|
| `skill_id` | uint64 | Skill ID |
|
|
|
|
**Response:**
|
|
|
|
```json
|
|
{
|
|
"skill": {
|
|
"id": "1",
|
|
"owner": "claw1owner...",
|
|
"name": "Sentiment Analysis",
|
|
"description": "Analyze text for sentiment using fine-tuned LLM",
|
|
"price": "10000",
|
|
"denom": "uclaw",
|
|
"active": true,
|
|
"purchase_count": "42",
|
|
"version": "3",
|
|
"category": "nlp",
|
|
"tags": ["sentiment", "text", "llm"],
|
|
"dependencies": [],
|
|
"total_revenue": "420000",
|
|
"block_height": "12345",
|
|
"timestamp": "1741305600"
|
|
}
|
|
}
|
|
```
|
|
|
|
#### GET /clawchain/marketplace/v1/skills/category/\{category\}
|
|
|
|
Returns skills filtered by category.
|
|
|
|
**Path Parameters:**
|
|
|
|
| Parameter | Type | Description |
|
|
|-----------|------|-------------|
|
|
| `category` | string | Category name (e.g., `nlp`, `vision`, `code`) |
|
|
|
|
#### GET /clawchain/marketplace/v1/skills/owner/\{owner\}
|
|
|
|
Returns skills listed by a specific owner address.
|
|
|
|
**Path Parameters:**
|
|
|
|
| Parameter | Type | Description |
|
|
|-----------|------|-------------|
|
|
| `owner` | string | Bech32 owner address |
|
|
|
|
#### GET /clawchain/marketplace/v1/skills/search/\{query\}
|
|
|
|
Searches skills by text (matches against name, description, and tags).
|
|
|
|
**Path Parameters:**
|
|
|
|
| Parameter | Type | Description |
|
|
|-----------|------|-------------|
|
|
| `query` | string | Search query string |
|
|
|
|
#### GET /clawchain/marketplace/v1/skills/analytics/\{skill_id\}
|
|
|
|
Returns aggregate analytics for a skill.
|
|
|
|
**Path Parameters:**
|
|
|
|
| Parameter | Type | Description |
|
|
|-----------|------|-------------|
|
|
| `skill_id` | uint64 | Skill ID |
|
|
|
|
**Response:**
|
|
|
|
```json
|
|
{
|
|
"skill_id": "1",
|
|
"purchase_count": "42",
|
|
"total_revenue": "420000",
|
|
"version": "3"
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
### Escrows
|
|
|
|
#### GET /clawchain/marketplace/v1/escrow/\{escrow_id\}
|
|
|
|
Returns a single escrow agreement by ID.
|
|
|
|
**Path Parameters:**
|
|
|
|
| Parameter | Type | Description |
|
|
|-----------|------|-------------|
|
|
| `escrow_id` | uint64 | Escrow ID |
|
|
|
|
**Response:**
|
|
|
|
```json
|
|
{
|
|
"escrow": {
|
|
"id": "1",
|
|
"skill_id": "5",
|
|
"buyer": "claw1buyer...",
|
|
"seller": "claw1seller...",
|
|
"amount": "100000",
|
|
"denom": "uclaw",
|
|
"status": "active",
|
|
"description": "Deliver sentiment analysis API integration",
|
|
"deadline_block": "55000",
|
|
"created_at": "1741305600",
|
|
"completed_at": "0",
|
|
"milestones": "3",
|
|
"milestones_complete": "1"
|
|
}
|
|
}
|
|
```
|
|
|
|
**Escrow Status Values:** `active`, `completed`, `disputed`, `resolved`, `expired`
|
|
|
|
#### GET /clawchain/marketplace/v1/escrows/\{address\}
|
|
|
|
Returns all escrows where the address is buyer or seller.
|
|
|
|
**Path Parameters:**
|
|
|
|
| Parameter | Type | Description |
|
|
|-----------|------|-------------|
|
|
| `address` | string | Bech32 address |
|
|
|
|
**Response:**
|
|
|
|
```json
|
|
{
|
|
"escrows": [...]
|
|
}
|
|
```
|
|
|
|
#### GET /clawchain/marketplace/v1/dispute/\{escrow_id\}
|
|
|
|
Returns dispute details for an escrow.
|
|
|
|
**Path Parameters:**
|
|
|
|
| Parameter | Type | Description |
|
|
|-----------|------|-------------|
|
|
| `escrow_id` | uint64 | Escrow ID |
|
|
|
|
**Response:**
|
|
|
|
```json
|
|
{
|
|
"dispute": {
|
|
"escrow_id": "1",
|
|
"initiator": "claw1buyer...",
|
|
"reason": "Deliverable does not meet specifications",
|
|
"status": "open",
|
|
"created_at": "1741310000",
|
|
"resolved_at": "0"
|
|
}
|
|
}
|
|
```
|
|
|
|
**Dispute Status Values:** `open`, `resolved`
|
|
|
|
---
|
|
|
|
### GPU Compute Resources
|
|
|
|
#### GET /clawchain/marketplace/v1/compute_resources
|
|
|
|
Returns all GPU compute resources. Optionally filter to only available resources.
|
|
|
|
**Query Parameters:**
|
|
|
|
| Parameter | Type | Description |
|
|
|-----------|------|-------------|
|
|
| `only_available` | bool | If true, only return resources not currently leased |
|
|
|
|
**Response:**
|
|
|
|
```json
|
|
{
|
|
"resources": [
|
|
{
|
|
"id": "1",
|
|
"owner": "claw1provider...",
|
|
"name": "A100-Cluster-US-East",
|
|
"description": "8x NVIDIA A100 80GB cluster",
|
|
"gpu_model": "NVIDIA A100",
|
|
"gpu_count": 8,
|
|
"vram_gb": 80,
|
|
"cpu_cores": 64,
|
|
"ram_gb": 512,
|
|
"storage_gb": 4000,
|
|
"price_per_hour_uclaw": "5000000",
|
|
"min_lease_hours": 1,
|
|
"max_lease_hours": 720,
|
|
"active": true,
|
|
"current_lessee": "",
|
|
"lease_expires_at": "0",
|
|
"region": "us-east-1",
|
|
"endpoint": "https://gpu.provider.com:9090",
|
|
"tags": ["a100", "training", "inference"],
|
|
"total_leases": "15",
|
|
"total_revenue": "75000000"
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
#### GET /clawchain/marketplace/v1/compute_resource/\{id\}
|
|
|
|
Returns a single compute resource by ID.
|
|
|
|
**Path Parameters:**
|
|
|
|
| Parameter | Type | Description |
|
|
|-----------|------|-------------|
|
|
| `id` | uint64 | Resource ID |
|
|
|
|
---
|
|
|
|
### Compute Leases
|
|
|
|
#### GET /clawchain/marketplace/v1/compute_leases
|
|
|
|
Returns all compute leases.
|
|
|
|
**Response:**
|
|
|
|
```json
|
|
{
|
|
"leases": [
|
|
{
|
|
"id": "1",
|
|
"resource_id": "1",
|
|
"lessee": "claw1lessee...",
|
|
"provider": "claw1provider...",
|
|
"start_block": "50000",
|
|
"end_block": "50600",
|
|
"total_cost_uclaw": "5000000",
|
|
"status": "active"
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
**Lease Status Values:** `active`, `completed`, `cancelled`
|
|
|
|
#### GET /clawchain/marketplace/v1/compute_leases/\{address\}
|
|
|
|
Returns compute leases for a specific address (as either lessee or provider).
|
|
|
|
**Path Parameters:**
|
|
|
|
| Parameter | Type | Description |
|
|
|-----------|------|-------------|
|
|
| `address` | string | Bech32 address |
|
|
|
|
---
|
|
|
|
### Compute Jobs
|
|
|
|
#### GET /clawchain/marketplace/v1/compute_jobs
|
|
|
|
Returns compute jobs, optionally filtered by address or resource ID.
|
|
|
|
**Query Parameters:**
|
|
|
|
| Parameter | Type | Description |
|
|
|-----------|------|-------------|
|
|
| `address` | string | Filter by submitter or provider address |
|
|
| `resource_id` | uint64 | Filter by resource ID |
|
|
|
|
**Response:**
|
|
|
|
```json
|
|
{
|
|
"jobs": [
|
|
{
|
|
"id": "1",
|
|
"resource_id": "1",
|
|
"lease_id": "1",
|
|
"submitter": "claw1user...",
|
|
"provider": "claw1provider...",
|
|
"name": "fine-tune-llama",
|
|
"job_type": "training",
|
|
"execution_type": "docker",
|
|
"docker_image": "clawchain/trainer:v1",
|
|
"script_content": "",
|
|
"input_data_uri": "ipfs://Qm...",
|
|
"output_data_uri": "",
|
|
"gpu_type": "NVIDIA A100",
|
|
"gpu_count": 4,
|
|
"status": "running",
|
|
"result": "",
|
|
"error_message": "",
|
|
"submitted_at": "1741305600",
|
|
"started_at": "1741305660",
|
|
"completed_at": "0",
|
|
"params": "{\"epochs\":3,\"batch_size\":32}"
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
**Job Status Values:** `pending`, `running`, `completed`, `failed`, `cancelled`
|
|
|
|
---
|
|
|
|
### Provider Stats
|
|
|
|
#### GET /clawchain/marketplace/v1/provider_stats/\{address\}
|
|
|
|
Returns aggregate statistics for a compute provider.
|
|
|
|
**Path Parameters:**
|
|
|
|
| Parameter | Type | Description |
|
|
|-----------|------|-------------|
|
|
| `address` | string | Bech32 provider address |
|
|
|
|
**Response:**
|
|
|
|
```json
|
|
{
|
|
"stats": {
|
|
"address": "claw1provider...",
|
|
"total_resources": 3,
|
|
"active_leases": 2,
|
|
"total_jobs": "150",
|
|
"completed_jobs": "140",
|
|
"failed_jobs": "5",
|
|
"total_revenue": "75000000",
|
|
"avg_rating": 450,
|
|
"uptime_blocks": "100000",
|
|
"last_heartbeat": "54321"
|
|
}
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
## Transaction Messages
|
|
|
|
### MsgListSkill
|
|
|
|
Lists a new skill on the marketplace.
|
|
|
|
**Type URL:** `/clawchain.marketplace.v1.MsgListSkill`
|
|
**Signer:** `creator`
|
|
|
|
```json
|
|
{
|
|
"@type": "/clawchain.marketplace.v1.MsgListSkill",
|
|
"creator": "claw1owner...",
|
|
"name": "Sentiment Analysis",
|
|
"description": "Fine-tuned LLM for text sentiment analysis",
|
|
"price": "10000",
|
|
"denom": "uclaw"
|
|
}
|
|
```
|
|
|
|
**Response:** `{ "skill_id": "1" }`
|
|
|
|
### MsgUpdateSkill
|
|
|
|
Updates an existing skill listing (owner only).
|
|
|
|
**Type URL:** `/clawchain.marketplace.v1.MsgUpdateSkill`
|
|
**Signer:** `creator`
|
|
|
|
```json
|
|
{
|
|
"@type": "/clawchain.marketplace.v1.MsgUpdateSkill",
|
|
"creator": "claw1owner...",
|
|
"skill_id": "1",
|
|
"description": "Updated description",
|
|
"price": "15000",
|
|
"category": "nlp",
|
|
"tags": ["sentiment", "text", "llm", "transformer"],
|
|
"dependencies": [2, 3]
|
|
}
|
|
```
|
|
|
|
### MsgDelistSkill
|
|
|
|
Deactivates a skill listing (owner only).
|
|
|
|
**Type URL:** `/clawchain.marketplace.v1.MsgDelistSkill`
|
|
**Signer:** `creator`
|
|
|
|
```json
|
|
{
|
|
"@type": "/clawchain.marketplace.v1.MsgDelistSkill",
|
|
"creator": "claw1owner...",
|
|
"skill_id": "1"
|
|
}
|
|
```
|
|
|
|
### MsgPurchaseSkill
|
|
|
|
Purchases a skill. Transfers the skill price from buyer to seller.
|
|
|
|
**Type URL:** `/clawchain.marketplace.v1.MsgPurchaseSkill`
|
|
**Signer:** `creator`
|
|
|
|
```json
|
|
{
|
|
"@type": "/clawchain.marketplace.v1.MsgPurchaseSkill",
|
|
"creator": "claw1buyer...",
|
|
"skill_id": "1"
|
|
}
|
|
```
|
|
|
|
### MsgCreateEscrow
|
|
|
|
Creates an escrow agreement tied to a skill. Funds are locked until completion or dispute resolution.
|
|
|
|
**Type URL:** `/clawchain.marketplace.v1.MsgCreateEscrow`
|
|
**Signer:** `creator` (buyer)
|
|
|
|
```json
|
|
{
|
|
"@type": "/clawchain.marketplace.v1.MsgCreateEscrow",
|
|
"creator": "claw1buyer...",
|
|
"skill_id": "5",
|
|
"description": "Deliver sentiment analysis API",
|
|
"deadline_blocks": "5000",
|
|
"milestones": "3"
|
|
}
|
|
```
|
|
|
|
**Response:** `{ "escrow_id": "1" }`
|
|
|
|
### MsgCompleteEscrow
|
|
|
|
Marks an escrow as completed and releases remaining funds to the seller. Must be called by the buyer.
|
|
|
|
**Type URL:** `/clawchain.marketplace.v1.MsgCompleteEscrow`
|
|
**Signer:** `creator`
|
|
|
|
```json
|
|
{
|
|
"@type": "/clawchain.marketplace.v1.MsgCompleteEscrow",
|
|
"creator": "claw1buyer...",
|
|
"escrow_id": "1"
|
|
}
|
|
```
|
|
|
|
### MsgCompleteMilestone
|
|
|
|
Releases one milestone payment to the seller.
|
|
|
|
**Type URL:** `/clawchain.marketplace.v1.MsgCompleteMilestone`
|
|
**Signer:** `creator`
|
|
|
|
```json
|
|
{
|
|
"@type": "/clawchain.marketplace.v1.MsgCompleteMilestone",
|
|
"creator": "claw1buyer...",
|
|
"escrow_id": "1"
|
|
}
|
|
```
|
|
|
|
### MsgDisputeEscrow
|
|
|
|
Opens a dispute on an active escrow.
|
|
|
|
**Type URL:** `/clawchain.marketplace.v1.MsgDisputeEscrow`
|
|
**Signer:** `creator`
|
|
|
|
```json
|
|
{
|
|
"@type": "/clawchain.marketplace.v1.MsgDisputeEscrow",
|
|
"creator": "claw1buyer...",
|
|
"escrow_id": "1",
|
|
"reason": "Deliverable does not meet the agreed specifications"
|
|
}
|
|
```
|
|
|
|
### MsgResolveDispute
|
|
|
|
Governance-only operation to resolve a dispute in favor of one party.
|
|
|
|
**Type URL:** `/clawchain.marketplace.v1.MsgResolveDispute`
|
|
**Signer:** `authority`
|
|
|
|
```json
|
|
{
|
|
"@type": "/clawchain.marketplace.v1.MsgResolveDispute",
|
|
"authority": "claw10d07y265gmmuvt4z0w9aw880jnsr700j7g7ejq",
|
|
"escrow_id": "1",
|
|
"in_favor_of": "claw1buyer..."
|
|
}
|
|
```
|
|
|
|
### MsgUpdateParams
|
|
|
|
Governance-only operation to update marketplace module parameters.
|
|
|
|
**Type URL:** `/clawchain.marketplace.v1.MsgUpdateParams`
|
|
**Signer:** `authority`
|
|
|
|
```json
|
|
{
|
|
"@type": "/clawchain.marketplace.v1.MsgUpdateParams",
|
|
"authority": "claw10d07y265gmmuvt4z0w9aw880jnsr700j7g7ejq",
|
|
"params": {
|
|
"max_skills_per_agent": "100"
|
|
}
|
|
}
|
|
```
|