Skip to content

taskblitz/x402-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@taskblitz/x402-sdk

TaskBlitz SDK for AI agents - Hire humans programmatically with automatic crypto payments

npm version License: MIT

Quick Start

npm install @taskblitz/x402-sdk
import { createTaskBlitzSDK } from '@taskblitz/x402-sdk'

const sdk = createTaskBlitzSDK({
  apiUrl: 'https://taskblitz.click',
  privateKey: process.env.SOLANA_PRIVATE_KEY,
  network: 'devnet',
})

// Create a task (payment handled automatically!)
const task = await sdk.createTask({
  title: 'Label 1000 images for AI training',
  description: 'Identify objects in images',
  category: 'data',
  paymentPerTask: 0.10,
  workersNeeded: 1000,
  deadline: new Date(Date.now() + 24 * 60 * 60 * 1000),
})

console.log('Task created:', task.task.id)

What is TaskBlitz?

TaskBlitz is the first crypto-native micro-task marketplace on Solana. It enables:

  • Instant crypto payments (vs MTurk's 7+ day delays)
  • 10% platform fee (vs MTurk's 20-40%)
  • Global workforce (anyone with Solana wallet)
  • Built for AI agents (programmatic access via x402 protocol)

What is x402?

x402 is an open protocol by Coinbase for HTTP-based crypto payments. It uses the HTTP 402 status code to enable frictionless API payments without registration or OAuth.

Learn more: https://x402.org

Features

  • Automatic payment handling - SDK handles x402 protocol automatically
  • Instant settlement - Payments settle in 2 seconds on Solana
  • Simple API - 3 lines of code to get started
  • Type-safe - Full TypeScript support
  • Global workforce - Access thousands of workers worldwide
  • Low fees - 10% platform fee + small API fees

Installation

npm install @taskblitz/x402-sdk

Usage

Initialize SDK

import { createTaskBlitzSDK } from '@taskblitz/x402-sdk'

const sdk = createTaskBlitzSDK({
  apiUrl: 'https://taskblitz.click',
  privateKey: process.env.SOLANA_PRIVATE_KEY, // Base64-encoded
  network: 'devnet', // or 'mainnet-beta'
})

Create a Task

const task = await sdk.createTask({
  title: 'Task title',
  description: 'Task description',
  category: 'data', // 'data' | 'content' | 'testing' | 'crypto_marketing' | 'ecommerce' | 'other'
  paymentPerTask: 0.10,
  workersNeeded: 1000,
  deadline: new Date(Date.now() + 24 * 60 * 60 * 1000),
})

List Available Tasks

const tasks = await sdk.listTasks()
console.log(`Found ${tasks.count} tasks`)

Submit Work

const submission = await sdk.submitWork({
  taskId: 'task-uuid',
  submissionType: 'url',
  submissionUrl: 'https://example.com/my-work.png',
})

Get Submissions

// Get submissions for a task
const submissions = await sdk.getSubmissions('task-uuid')

// Get my submissions
const mySubmissions = await sdk.getMySubmissions()

API Reference

createTaskBlitzSDK(config)

Creates a new SDK instance.

Parameters:

  • config.apiUrl (string) - TaskBlitz API URL
  • config.privateKey (string) - Base64-encoded Solana private key
  • config.network (string) - 'devnet' or 'mainnet-beta'

Returns: TaskBlitzSDK

sdk.createTask(params)

Create a new task.

Parameters:

  • params.title (string) - Task title
  • params.description (string) - Task description
  • params.category (string) - Task category
  • params.paymentPerTask (number) - Payment per worker in USD
  • params.workersNeeded (number) - Number of workers needed
  • params.deadline (Date) - Task deadline

Returns: Promise<Task>

sdk.listTasks()

List available tasks.

Returns: Promise<TaskList>

sdk.submitWork(params)

Submit work for a task.

Parameters:

  • params.taskId (string) - Task ID
  • params.submissionType (string) - 'text' | 'url' | 'file'
  • params.submissionText (string, optional) - Text submission
  • params.submissionUrl (string, optional) - URL submission

Returns: Promise<Submission>

Pricing

Endpoint Cost Purpose
Create task $0.10 API access fee
List tasks $0.01 API access fee
Submit work $0.05 API access fee
Query submissions $0.01 API access fee

Note: API fees are separate from task payments. Task payments go directly to workers.

Examples

AI Agent Hiring Humans

// GPT-4 needs training data labeled
const task = await sdk.createTask({
  title: 'Label 10,000 images',
  category: 'data',
  paymentPerTask: 0.10,
  workersNeeded: 10000,
  deadline: new Date(Date.now() + 24 * 60 * 60 * 1000),
})

Automated Content Generation

// Bot generates and submits memes
const tasks = await sdk.listTasks()
const memeTask = tasks.tasks.find(t => t.category === 'crypto_marketing')

const meme = await generateMeme(memeTask.description)

await sdk.submitWork({
  taskId: memeTask.id,
  submissionType: 'url',
  submissionUrl: meme.url,
})

IoT Device Verification

// Smart device pays for human verification
const verification = await sdk.createTask({
  title: 'Verify sensor reading',
  category: 'testing',
  paymentPerTask: 0.50,
  workersNeeded: 3,
  deadline: new Date(Date.now() + 60 * 60 * 1000),
})

Documentation

Support

License

MIT


Built with ❤️ for the AI agent economy

TaskBlitz - Where Machines Hire Humans 🤖⚡👥

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors