AI Service Marketplace
The AI Service Marketplace is a comprehensive platform for discovering, monetizing, and managing AI services with built-in reputation management, subscriptions, and payment infrastructure.
Features
🔍 Service Discovery
- Search and filter services by category, price, rating
- Sort by popularity, rating, or newest
- Tag-based organization
- Real-time service health monitoring
⭐ Reputation System
- On-chain ratings (1-5 stars)
- Verified reviews from paying customers
- Weighted rating calculation
- Review helpfulness voting
- Spam/abuse reporting
💳 Flexible Pricing
- Pay-per-use: Single API call payments
- Subscriptions: Daily, weekly, monthly, annual plans
- Free tiers: Limited free requests
- Multi-token support: USDC, DAI, USDT
🔒 Security & Trust
- On-chain escrow for payments
- Dispute resolution system
- Automatic refunds for violations
- Service health monitoring
- Uptime guarantees
📊 Analytics
- Real-time usage metrics
- Revenue tracking
- Customer analytics
- Performance monitoring
- Churn analysis
Quick Start
Installation
Register Your Service
import { MarketplaceService } from '@nirholas/universal-crypto-mcp-marketplace';
const marketplace = new MarketplaceService({
chain: 'arbitrum',
privateKey: process.env.PRIVATE_KEY
});
// Register your AI service
const service = await marketplace.registerService({
name: 'Advanced Weather Predictions',
description: 'AI-powered weather forecasting with 95% accuracy',
category: 'weather',
endpoint: 'https://api.weather-ai.com',
pricing: {
payPerUse: '$0.001', // $0.001 per API call
subscription: {
monthly: '$9.99',
annually: '$99.99'
},
freeTier: {
requestsPerDay: 100,
features: ['Basic forecasts', 'Hourly data']
}
},
metadata: {
responseTime: '< 100ms',
uptime: '99.9%',
apiVersion: 'v2',
documentation: 'https://docs.weather-ai.com',
supportEmail: '[email protected]'
},
tags: ['weather', 'ai', 'forecasting', 'real-time'],
walletAddress: '0x...' // Your payment wallet
});
console.log(`Service registered with ID: ${service.id}`);
Discover and Use Services
// Find the best weather API
const services = await marketplace.discoverServices({
category: 'weather',
maxPrice: '$0.01',
minRating: 4.5,
sortBy: 'rating',
limit: 5
});
console.log(`Found ${services.length} weather services`);
// Subscribe to the best one
const bestService = services[0];
const subscription = await marketplace.subscribe({
serviceId: bestService.id,
plan: 'monthly',
paymentToken: 'USDC',
autoRenew: true
});
console.log(`Subscribed until ${subscription.expiresAt}`);
// Use the service
const response = await fetch(bestService.endpoint, {
headers: {
'X-Subscription-Id': subscription.id
}
});
Rate a Service
// Leave a review after using
await marketplace.rateService({
serviceId: bestService.id,
rating: 5,
review: 'Incredibly accurate! Best weather API I\'ve used.',
tags: ['accurate', 'fast', 'reliable']
});
API Reference
MarketplaceService
Constructor
Config Options:
- chain: Blockchain network ('ethereum' | 'arbitrum' | 'base')
- privateKey: Your wallet private key
- contractAddress?: Custom marketplace contract
- rpcUrl?: Custom RPC endpoint
- facilitatorUrl?: x402 facilitator URL
registerService()
Register a new AI service in the marketplace.
Parameters:
- name: Service name (3-100 chars)
- description: Detailed description (10-1000 chars)
- category: Service category
- endpoint: API endpoint URL
- pricing: Pricing configuration
- metadata?: Additional service info
- tags?: Search tags
- walletAddress: Payment destination
Returns: Registered service with ID
discoverServices()
Find services matching criteria.
Filter Options:
- category?: Filter by category
- minRating?: Minimum rating (0-5)
- maxPrice?: Maximum price (e.g., "$0.01")
- tags?: Filter by tags
- sortBy?: Sort order ('rating' | 'price' | 'popularity' | 'newest')
- limit?: Max results (1-100)
- offset?: Pagination offset
Returns: Array of matching services
subscribe()
Subscribe to a service.
Parameters:
- serviceId: Service to subscribe to
- plan: Subscription plan ('daily' | 'weekly' | 'monthly' | 'annually')
- paymentToken: Payment token symbol
- autoRenew?: Enable auto-renewal
Returns: Subscription details
rateService()
Submit a rating and review.
Parameters:
- serviceId: Service to rate
- rating: Rating (1-5 stars)
- review?: Text review (max 1000 chars)
- tags?: Review tags
Returns: Rating record
getAnalytics()
Get service analytics (owner only).
await marketplace.getAnalytics(
serviceId: string,
period?: 'day' | 'week' | 'month' | 'year'
): Promise<ServiceAnalytics>
Returns: Analytics data including: - Request count - Revenue - Subscriber metrics - Performance stats - Rating trends
SubscriptionManager
Manages on-chain subscriptions.
import { SubscriptionManager } from '@nirholas/universal-crypto-mcp-marketplace';
const manager = new SubscriptionManager({
contractAddress: '0x...',
tokenAddress: '0x...', // USDC address
chain: 'arbitrum',
privateKey: process.env.PRIVATE_KEY
});
subscribe()
Create on-chain subscription.
isActive()
Check if subscription is active.
cancelSubscription()
Cancel subscription.
Service Categories
ai-ml- AI & Machine Learningdata- Data Servicesweather- Weather & Climatefinance- Financial Datasocial- Social Mediagaming- Gaming Servicesmedia- Media Processinganalytics- Analytics & Insightssecurity- Security Servicesother- Other Services
Pricing Examples
Pay-Per-Use
Subscription Plans
pricing: {
subscription: {
daily: '$0.99',
weekly: '$4.99',
monthly: '$9.99',
annually: '$99.99'
}
}
Free Tier + Paid
pricing: {
payPerUse: '$0.01',
freeTier: {
requestsPerDay: 100,
features: ['Basic API', 'Standard support']
}
}
Smart Contract
The marketplace uses an on-chain smart contract for:
- Service registry
- Payment escrow
- Reputation scores
- Subscription management
- Dispute resolution
Contract Address (Arbitrum): 0x... (TBD)
Key Functions:
- registerService() - Register new service
- payForRequest() - Pay for single request
- subscribe() - Create subscription
- rateService() - Submit rating
- fileDispute() - File dispute
- withdrawEarnings() - Withdraw revenue
Dispute Resolution
If a service fails to deliver:
// File a dispute
const dispute = await marketplace.fileDispute(
serviceId,
'Service did not respond within SLA',
['https://proof-screenshot.png']
);
// Platform reviews dispute
// Automatic refund if service violated terms
Dispute Process: 1. Customer files dispute with evidence 2. Platform investigates (24-48 hours) 3. Service owner responds 4. Resolution: refund, partial refund, or rejection 5. On-chain record of all disputes
Analytics Dashboard
Track your service performance:
const analytics = await marketplace.getAnalytics(serviceId, 'month');
console.log(`
Requests: ${analytics.requests}
Revenue: ${analytics.revenue}
New Subscribers: ${analytics.newSubscribers}
Churn Rate: ${(analytics.churnedSubscribers / analytics.newSubscribers * 100).toFixed(1)}%
Avg Response Time: ${analytics.averageResponseTime}ms
Error Rate: ${(analytics.errorRate * 100).toFixed(2)}%
Rating: ${(analytics.rating / 100).toFixed(1)}⭐
`);
REST API Server
Run a marketplace API server:
import { startMarketplaceAPI } from '@nirholas/universal-crypto-mcp-marketplace';
await startMarketplaceAPI({
port: 3000,
chain: 'arbitrum',
privateKey: process.env.PRIVATE_KEY,
contractAddress: '0x...',
tokenAddress: '0x...', // USDC
cors: true
});
Endpoints:
- POST /api/services - Register service
- GET /api/services - Discover services
- GET /api/services/:id - Get service details
- PATCH /api/services/:id - Update service
- POST /api/ratings - Submit rating
- GET /api/services/:id/ratings - Get ratings
- POST /api/subscriptions - Create subscription
- POST /api/subscriptions/:id/cancel - Cancel subscription
- GET /api/services/:id/analytics - Get analytics
- POST /api/disputes - File dispute
Examples
See the examples directory for:
- Weather API Service - Complete weather service with marketplace integration
- Trading Signals - Paid trading signal service
- AI Image Generation - Subscription-based image API
- Data Analytics - Pay-per-query analytics service
Best Practices
For Service Providers
- Accurate Pricing: Set fair, competitive prices
- Clear Documentation: Provide comprehensive API docs
- Reliable Service: Maintain high uptime (>99%)
- Fast Response: Keep latency low (<200ms)
- Good Support: Respond to issues quickly
- Transparent Limits: Clearly state rate limits
- Security: Use HTTPS, validate inputs
- Monitoring: Track errors and performance
For Service Consumers
- Check Ratings: Look for 4+ star services
- Read Reviews: Read actual user experiences
- Test First: Use free tier before subscribing
- Monitor Usage: Track API call costs
- Report Issues: File disputes if service fails
- Leave Reviews: Help others with honest feedback
Security
- All payments go through on-chain escrow
- Private keys never exposed to marketplace
- Service endpoints verified via DNS
- Rate limiting prevents abuse
- Dispute system protects consumers
- Spam detection for fake reviews
Roadmap
- [ ] Multi-chain deployment (Ethereum, Base, Polygon)
- [ ] Service bundling (package multiple services)
- [ ] Referral rewards
- [ ] API key management
- [ ] Usage webhooks
- [ ] Custom analytics
- [ ] White-label marketplace
- [ ] Mobile SDKs
Support
- Documentation: docs.universal-crypto-mcp.com
- Issues: GitHub Issues
- Discord: Coming soon
License
Apache-2.0