Claim Tasks
Claim Tasks
Section titled “Claim Tasks”Learn how to claim AI inference tasks in the Hyra Network and start earning HYRA tokens as an AI worker.
What are AI Tasks?
Section titled “What are AI Tasks?”AI tasks in Hyra Network are AI inference requests that users pay for and AI workers process to earn rewards. These tasks include:
- Text Generation: LLM chat, content creation, translation
- Image Processing: Classification, object detection, style transfer
- Audio Processing: Speech recognition, music generation
- Data Analysis: Pattern recognition, prediction modeling
How to Claim Tasks
Section titled “How to Claim Tasks”1. Initialize the SDK
Section titled “1. Initialize the SDK”from hyra_sdk import HyraClient
# Initialize clientclient = HyraClient()const { HyraClient } = require("@hyra-network/sdk");
// Initialize clientconst client = new HyraClient();2. Check Available Tasks
Section titled “2. Check Available Tasks”# Get global statisticsstats = client.get_global_stats()print(f"Available tasks: {stats['total_available_tasks']}")print(f"Active pools: {stats['total_active_pools']}")// Get global statisticsconst stats = await client.getGlobalStats();console.log(`Available tasks: ${stats.totalAvailableTasks}`);console.log(`Active pools: ${stats.totalActivePools}`);3. Claim a Task
Section titled “3. Claim a Task”# Claim the best available tasktask = client.claim_task()print(f"Task ID: {task['task_id']}")print(f"Model: {task['model_name']}")print(f"Input: {task['input_data']}")print(f"Reward: {task['reward']} wei")// Claim the best available taskconst task = await client.claimTask();console.log(`Task ID: ${task.taskId}`);console.log(`Model: ${task.modelName}`);console.log(`Input: ${task.inputData}`);console.log(`Reward: ${task.reward} wei`);Task Information
Section titled “Task Information”When you claim a task, you’ll receive:
Task Details
Section titled “Task Details”- Task ID: Unique identifier for the task
- Model Name: AI model to use for processing
- Input Data: The prompt or input to process
- Reward: HYRA tokens you’ll earn for completion
- Deadline: When the task expires
- Pool Address: Smart contract address for submission
Supported AI Models
Section titled “Supported AI Models”# Get all available modelsmodels = client.get_supported_models()for model in models: print(f"Model: {model['modelName']}") print(f"Price: {model['modelTokenPrice']} wei per token") print(f"Active: {model['modelIsActive']}")// Get all available modelsconst models = await client.getSupportedModels();models.forEach((model) => { console.log(`Model: ${model.modelName}`); console.log(`Price: ${model.modelTokenPrice} wei per token`); console.log(`Active: ${model.modelIsActive}`);});ZKP Anti-Cheating System
Section titled “ZKP Anti-Cheating System”Why ZKP is Required
Section titled “Why ZKP is Required”The Zero-Knowledge Proof system prevents AI workers from cheating by:
- Proving Computation: You must generate cryptographic proof you actually ran the AI model
- Hiding Private Data: Your computation process remains private
- Verifying Correctness: Verifiers can confirm you did the work without re-running it
- Preventing Lazy Workers: You cannot submit random results without doing the work
How ZKP Works
Section titled “How ZKP Works”- You Process the Task: Run the AI model with the input data
- Generate ZKP Proof: Create cryptographic proof of your computation
- Submit with Proof: Submit both result and proof to the smart contract
- Verifier Validates: Verifiers check your proof without seeing your process
- Get Rewarded: If proof is valid, you receive HYRA tokens
Task Management
Section titled “Task Management”Check Your Active Task
Section titled “Check Your Active Task”# Check if you have an active taskstatus = client.get_task_status()if status['has_active_task']: print(f"Active task: {status['active_task_id']}") print(f"Deadline: {status['deadline']}") print(f"Reward: {status['reward']} wei")else: print("No active task")// Check if you have an active taskconst status = await client.getTaskStatus();if (status.hasActiveTask) { console.log(`Active task: ${status.activeTaskId}`); console.log(`Deadline: ${status.deadline}`); console.log(`Reward: ${status.reward} wei`);} else { console.log("No active task");}Task Requirements
Section titled “Task Requirements”Before claiming a task, ensure you have:
- Sufficient HYRA Balance: For gas fees and potential penalties
- AI Model Access: Ability to run the required AI model
- Computational Resources: CPU/GPU for AI processing
- ZKP Capability: Ability to generate zero-knowledge proofs
- Network Connectivity: Stable internet connection
Privacy and Security
Section titled “Privacy and Security”Encrypted Data Handling
Section titled “Encrypted Data Handling”- Input Encryption: Task inputs are encrypted before submission to smart contracts
- Output Encryption: Your results are encrypted during transmission
- ZKP Privacy: Zero-knowledge proofs verify computation without revealing your process
- No Data Leakage: Your AI model and computation process remain private
Security Best Practices
Section titled “Security Best Practices”# Always verify task data before processingdef process_task_safely(task): # Validate input data if not task['input_data']: raise ValueError("Invalid input data")
# Process with your AI model result = your_ai_model.process(task['input_data'])
# Generate ZKP proof (handled by SDK) return result// Always verify task data before processingasync function processTaskSafely(task) { // Validate input data if (!task.inputData) { throw new Error("Invalid input data"); }
// Process with your AI model const result = await yourAIModel.process(task.inputData);
// Generate ZKP proof (handled by SDK) return result;}Error Handling
Section titled “Error Handling”Common Errors
Section titled “Common Errors”try: task = client.claim_task()except Exception as e: if "UserHasActiveTask" in str(e): print("You already have an active task") elif "NoAvailableTask" in str(e): print("No tasks available, try again later") elif "InsufficientBalance" in str(e): print("Insufficient HYRA balance") else: print(f"Error: {e}")try { const task = await client.claimTask();} catch (error) { if (error.message.includes("UserHasActiveTask")) { console.log("You already have an active task"); } else if (error.message.includes("NoAvailableTask")) { console.log("No tasks available, try again later"); } else if (error.message.includes("InsufficientBalance")) { console.log("Insufficient HYRA balance"); } else { console.log(`Error: ${error.message}`); }}Task Lifecycle
Section titled “Task Lifecycle”Complete Workflow
Section titled “Complete Workflow”- Claim Task → Get task details and requirements
- Process Task → Run AI model with input data
- Generate ZKP → Create cryptographic proof of computation
- Submit Result → Submit result and proof to smart contract
- Verification → Verifiers validate your proof
- Get Rewarded → Receive HYRA tokens if proof is valid
Time Management
Section titled “Time Management”- Task Deadlines: Each task has a deadline for completion
- Processing Time: Factor in time for AI processing and ZKP generation
- Submission Time: Allow time for blockchain transaction confirmation
- Verification Time: Verifiers need time to validate your proof
Best Practices
Section titled “Best Practices”For AI Workers
Section titled “For AI Workers”- Choose Appropriate Tasks: Select tasks you can complete within the deadline
- Maintain Quality: Ensure your AI results are accurate and relevant
- Monitor Deadlines: Don’t let tasks expire
- Secure Your Setup: Protect your private keys and computational resources
- Stay Updated: Keep your AI models and SDKs updated
For Task Processing
Section titled “For Task Processing”- Validate Inputs: Always check task input data before processing
- Use Reliable Models: Ensure your AI models are working correctly
- Test Your Setup: Verify your ZKP generation works before claiming tasks
- Monitor Performance: Track your success rate and earnings
Next Steps
Section titled “Next Steps”Ready to process your claimed tasks? Check out our Process Tasks guide to learn how to run AI models and generate ZKP proofs.