Skip to content

Claim Tasks

Learn how to claim AI inference tasks in the Hyra Network and start earning HYRA tokens as an AI worker.

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
from hyra_sdk import HyraClient
# Initialize client
client = HyraClient()
const { HyraClient } = require("@hyra-network/sdk");
// Initialize client
const client = new HyraClient();
# Get global statistics
stats = client.get_global_stats()
print(f"Available tasks: {stats['total_available_tasks']}")
print(f"Active pools: {stats['total_active_pools']}")
// Get global statistics
const stats = await client.getGlobalStats();
console.log(`Available tasks: ${stats.totalAvailableTasks}`);
console.log(`Active pools: ${stats.totalActivePools}`);
# Claim the best available task
task = 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 task
const 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`);

When you claim a task, you’ll receive:

  • 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
# Get all available models
models = 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 models
const 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}`);
});

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
  1. You Process the Task: Run the AI model with the input data
  2. Generate ZKP Proof: Create cryptographic proof of your computation
  3. Submit with Proof: Submit both result and proof to the smart contract
  4. Verifier Validates: Verifiers check your proof without seeing your process
  5. Get Rewarded: If proof is valid, you receive HYRA tokens
# Check if you have an active task
status = 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 task
const 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");
}

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
  • 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
# Always verify task data before processing
def 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 processing
async 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;
}
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}`);
}
}
  1. Claim Task → Get task details and requirements
  2. Process Task → Run AI model with input data
  3. Generate ZKP → Create cryptographic proof of computation
  4. Submit Result → Submit result and proof to smart contract
  5. Verification → Verifiers validate your proof
  6. Get Rewarded → Receive HYRA tokens if proof is valid
  • 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
  • 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
  • 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

Ready to process your claimed tasks? Check out our Process Tasks guide to learn how to run AI models and generate ZKP proofs.