Skip to content

Distributed AI Network

Hyra Network implements a fully decentralized AI architecture where all task distribution, reward management, and data handling are managed by smart contracts on the blockchain, eliminating the need for centralized backend systems.

┌─────────────────────────────────────────────────────────────┐
│ Centralized Backend │
│ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Server │ │ Database │ │ API │ │
│ │ │ │ │ │ │ │
│ │• Task Mgmt │ │• User Data │ │• Endpoints │ │
│ │• Rewards │ │• Task Data │ │• Auth │ │
│ │• Processing │ │• Results │ │• Rate Limit │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
└─────────────────────────────────────────────────────────────┘

Problems with Backend Approach:

  • Single Point of Failure: Server downtime affects entire network
  • Centralized Control: Backend operator controls all data and rewards
  • Privacy Concerns: All data stored on centralized servers
  • Scalability Issues: Limited by server capacity
  • Trust Requirements: Users must trust the backend operator
┌──────────────────────────────────────────────────────────────┐
│ Hyra Network Blockchain │
│ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │Task Pool │ │Model │ │Reward │ │
│ │Factory │ │Registry │ │Manager │ │
│ │ │ │ │ │ │ │
│ │• Task Mgmt │ │• AI Models │ │• HYRA Dist │ │
│ │• Assignment │ │• Pricing │ │• Staking │ │
│ │• Validation │ │• Versioning │ │• Governance │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ Public Blockchain Data │ │
│ │ │ │
│ │ • All task data is public and verifiable │ │
│ │ • No centralized authority controls the system │ │
│ │ • Transparent reward distribution │ │
│ │ • Decentralized governance │ │
│ └─────────────────────────────────────────────────────┘ │
└──────────────────────────────────────────────────────────────┘

Benefits of On-Chain Approach:

  • Decentralized: No single point of failure
  • Transparent: All operations are public and verifiable
  • Trustless: No need to trust a central authority
  • Immutable: Smart contract logic cannot be changed arbitrarily
  • Global: Accessible from anywhere in the world
contract ModelRegistry {
struct Model {
string modelName;
string modelDescription;
uint256 modelTokenPrice;
bool modelIsActive;
address modelOwner;
}
// Register new AI models
function registerModel(string memory name, string memory description, uint256 price) external;
// Get model information
function getModel(uint256 modelId) external view returns (Model memory);
// Update model pricing
function updateModelPrice(uint256 modelId, uint256 newPrice) external;
}

Responsibilities:

  • Model Management: Register and manage AI models
  • Pricing: Set and update model pricing in HYRA tokens
  • Versioning: Track model versions and updates
  • Access Control: Manage model ownership and permissions
contract TaskPoolFactory {
// Create new task pools
function createTaskPool(string memory name, address modelAddress) external returns (address);
// Get all task pools
function getAllTaskPools() external view returns (address[] memory);
// Get task pool by ID
function getTaskPool(uint256 poolId) external view returns (address);
}

Responsibilities:

  • Pool Creation: Create new task pools for different AI models
  • Pool Management: Track and manage all task pools
  • Pool Discovery: Allow workers to find available pools
contract TaskPoolImplementation {
struct Task {
uint256 taskId;
string inputData;
string expectedOutput;
uint256 reward;
uint256 deadline;
address assignedWorker;
bool isCompleted;
}
// Submit new tasks
function submitTask(string memory inputData, uint256 reward) external payable;
// Claim tasks
function claimTask() external returns (Task memory);
// Submit results
function submitResult(uint256 taskId, string memory result, bytes memory zkpProof) external;
}

Responsibilities:

  • Task Management: Create, assign, and track tasks
  • Worker Assignment: Assign tasks to available workers
  • Result Submission: Handle task result submissions
  • Reward Distribution: Distribute HYRA tokens to workers
contract TaskRouter {
// Route tasks to appropriate pools
function routeTask(uint256 modelId, string memory inputData) external payable;
// Get available tasks
function getAvailableTasks() external view returns (Task[] memory);
// Worker task management
function claimTaskFromPool(address poolAddress) external returns (Task memory);
}

Responsibilities:

  • Task Routing: Route tasks to appropriate pools
  • Load Balancing: Distribute tasks across multiple pools
  • Worker Discovery: Help workers find available tasks
  • Pool Coordination: Coordinate between different task pools

All data is stored on-chain and is publicly accessible:

// Task data structure
struct Task {
uint256 taskId; // Unique task identifier
string inputData; // Encrypted input data
string expectedOutput; // Expected output format
uint256 reward; // HYRA token reward
uint256 deadline; // Task deadline
address assignedWorker; // Worker address
bool isCompleted; // Completion status
bytes zkpProof; // Zero-knowledge proof
}
// Worker data structure
struct Worker {
address workerAddress; // Worker wallet address
uint256 totalTasks; // Total tasks completed
uint256 totalRewards; // Total HYRA earned
uint256 reputation; // Worker reputation score
bool isActive; // Active status
}
  • Task History: All tasks are publicly visible
  • Worker Performance: Worker statistics are public
  • Reward Distribution: All payments are transparent
  • Model Performance: AI model statistics are public
  • Submit Tasks: Pay HYRA tokens and submit AI inference requests
  • Access Results: Retrieve completed AI results
  • Model Selection: Choose from available AI models
  • Payment: Pay for services using HYRA tokens
  • Claim Tasks: Get tasks from smart contracts
  • Process Tasks: Run AI models and generate results
  • Submit Results: Submit results with ZKP proofs
  • Earn Rewards: Receive HYRA tokens for completed tasks
  • Verify Proofs: Validate ZKP proofs submitted by workers
  • Distribute Rewards: Trigger reward distribution to workers
  • Maintain Quality: Ensure network quality and prevent cheating
  • Governance: Participate in network governance
  • No Single Point of Failure: Network continues even if some nodes fail
  • No Central Authority: No single entity controls the network
  • Global Access: Anyone can participate from anywhere
  • Censorship Resistant: Cannot be shut down by authorities
  • Public Data: All operations are visible on blockchain
  • Verifiable: Anyone can verify network operations
  • Auditable: Complete audit trail of all activities
  • Trustless: No need to trust central authorities
  • Cryptographic Guarantees: Smart contracts provide security guarantees
  • Immutable Logic: Contract logic cannot be changed arbitrarily
  • ZKP Verification: Zero-knowledge proofs ensure computation integrity
  • Encrypted Data: All sensitive data is encrypted
  • Automated Operations: Smart contracts handle all operations automatically
  • Reduced Costs: No need for centralized infrastructure
  • Global Scale: Handle operations at global scale
  • 24/7 Availability: Network operates continuously
// User submits task to ModelRegistry
function submitInferenceRequest(uint256 modelId, string memory inputData) external payable {
// Validate payment
require(msg.value >= modelPrice, "Insufficient payment");
// Create task in appropriate pool
address poolAddress = getTaskPoolForModel(modelId);
TaskPoolImplementation pool = TaskPoolImplementation(poolAddress);
pool.submitTask(inputData, msg.value);
}
// Worker claims task from pool
function claimTask() external returns (Task memory) {
// Check if worker has active task
require(activeTasks[msg.sender] == 0, "Worker has active task");
// Assign task to worker
Task memory task = getNextAvailableTask();
activeTasks[msg.sender] = task.taskId;
return task;
}
// Worker submits result with ZKP proof
function submitResult(uint256 taskId, string memory result, bytes memory zkpProof) external {
// Verify ZKP proof
require(verifyZKPProof(taskId, result, zkpProof), "Invalid ZKP proof");
// Update task status
tasks[taskId].isCompleted = true;
tasks[taskId].result = result;
// Distribute reward
uint256 reward = tasks[taskId].reward;
payable(msg.sender).transfer(reward);
}
// Connect to Hyra Network
const provider = new ethers.providers.JsonRpcProvider(
"https://rpc.hyra.network"
);
const wallet = new ethers.Wallet(PRIVATE_KEY, provider);
// Get task from smart contract
const taskPool = new ethers.Contract(TASK_POOL_ADDRESS, TASK_POOL_ABI, wallet);
const task = await taskPool.claimTask();
// Submit result
await taskPool.submitResult(task.taskId, result, zkpProof);
// Listen to smart contract events
taskPool.on("TaskCompleted", (taskId, worker, reward) => {
console.log(`Task ${taskId} completed by ${worker} for ${reward} HYRA`);
});
  • Advanced Smart Contracts: More sophisticated contract logic
  • Cross-Chain Integration: Connect with other blockchains
  • Mobile DApps: Mobile applications for the network
  • Enterprise Solutions: Business-focused features
  • Optimized Smart Contracts: More efficient contract designs
  • Advanced ZKP Integration: Better ZKP integration
  • Scalability Solutions: Layer 2 solutions for scaling
  • Privacy Enhancements: Advanced privacy features

Ready to build on the decentralized AI network? Check out our guides: