Monitoring Rewards
Monitoring Rewards
Section titled “Monitoring Rewards”Learn how to monitor your HYRA token earnings, track task performance, and manage your rewards in the Hyra Network.
Overview
Section titled “Overview”The monitoring system allows you to:
- Track Earnings: Monitor your HYRA token balance and earnings
- View Transaction History: See all your task submissions and rewards
- Monitor ZKP Status: Track proof verification and validation
- Analyze Performance: Understand your task completion success rate
- Manage Rewards: Withdraw tokens and manage your earnings
Getting Started with Monitoring
Section titled “Getting Started with Monitoring”1. Initialize the Client
Section titled “1. Initialize the Client”from hyra_sdk import HyraClient
# Initialize clientclient = HyraClient()const { HyraClient } = require("@hyra-network/sdk");
// Initialize clientconst client = new HyraClient();2. Check Your Balance
Section titled “2. Check Your Balance”# Get your current HYRA token balancebalance = client.get_balance()print(f"Current Balance: {balance['tokens']} HYRA")print(f"Pending Rewards: {balance['pending']} HYRA")print(f"Total Earned: {balance['total_earned']} HYRA")// Get your current HYRA token balanceconst balance = await client.getBalance();console.log(`Current Balance: ${balance.tokens} HYRA`);console.log(`Pending Rewards: ${balance.pending} HYRA`);console.log(`Total Earned: ${balance.totalEarned} HYRA`);Core Monitoring Methods
Section titled “Core Monitoring Methods”1. Balance Tracking
Section titled “1. Balance Tracking”Get Current Balance
Section titled “Get Current Balance”# Get detailed balance informationbalance = client.get_balance()
# Balance structure:{ "tokens": int, # Available HYRA tokens "pending": int, # Pending rewards "total_earned": int, # Total lifetime earnings "withdrawn": int, # Total withdrawn amount "staked": int # Staked tokens (if applicable)}// Get detailed balance informationconst balance = await client.getBalance();
// Balance structure:{ tokens: number, // Available HYRA tokens pending: number, // Pending rewards totalEarned: number, // Total lifetime earnings withdrawn: number, // Total withdrawn amount staked: number // Staked tokens (if applicable)}Get Balance History
Section titled “Get Balance History”# Get balance history over timehistory = client.get_balance_history(days=30)for entry in history: print(f"Date: {entry['date']}") print(f"Balance: {entry['balance']} HYRA") print(f"Change: {entry['change']} HYRA")// Get balance history over timeconst history = await client.getBalanceHistory(30); // 30 dayshistory.forEach((entry) => { console.log(`Date: ${entry.date}`); console.log(`Balance: ${entry.balance} HYRA`); console.log(`Change: ${entry.change} HYRA`);});2. Transaction History
Section titled “2. Transaction History”Get All Transactions
Section titled “Get All Transactions”# Get your transaction historytransactions = client.get_transaction_history()for tx in transactions: print(f"Type: {tx['type']}") print(f"Amount: {tx['amount']} HYRA") print(f"Date: {tx['timestamp']}") print(f"Task ID: {tx['task_id']}") print(f"Status: {tx['status']}") print("---")// Get your transaction historyconst transactions = await client.getTransactionHistory();transactions.forEach((tx) => { console.log(`Type: ${tx.type}`); console.log(`Amount: ${tx.amount} HYRA`); console.log(`Date: ${tx.timestamp}`); console.log(`Task ID: ${tx.taskId}`); console.log(`Status: ${tx.status}`); console.log("---");});Filter Transactions
Section titled “Filter Transactions”# Filter by transaction typerewards = client.get_transaction_history(type="reward")submissions = client.get_transaction_history(type="submission")
# Filter by date rangerecent = client.get_transaction_history(days=7)
# Filter by statuspending = client.get_transaction_history(status="pending")completed = client.get_transaction_history(status="completed")// Filter by transaction typeconst rewards = await client.getTransactionHistory({ type: "reward" });const submissions = await client.getTransactionHistory({ type: "submission" });
// Filter by date rangeconst recent = await client.getTransactionHistory({ days: 7 });
// Filter by statusconst pending = await client.getTransactionHistory({ status: "pending" });const completed = await client.getTransactionHistory({ status: "completed" });3. Task Performance Tracking
Section titled “3. Task Performance Tracking”Get Task Statistics
Section titled “Get Task Statistics”# Get your task performance statisticsstats = client.get_task_statistics()print(f"Total Tasks: {stats['total_tasks']}")print(f"Completed: {stats['completed']}")print(f"Success Rate: {stats['success_rate']}%")print(f"Average Reward: {stats['avg_reward']} HYRA")print(f"Total Earnings: {stats['total_earnings']} HYRA")// Get your task performance statisticsconst stats = await client.getTaskStatistics();console.log(`Total Tasks: ${stats.totalTasks}`);console.log(`Completed: ${stats.completed}`);console.log(`Success Rate: ${stats.successRate}%`);console.log(`Average Reward: ${stats.avgReward} HYRA`);console.log(`Total Earnings: ${stats.totalEarnings} HYRA`);Get Task History
Section titled “Get Task History”# Get detailed task historytasks = client.get_task_history()for task in tasks: print(f"Task ID: {task['task_id']}") print(f"Model: {task['model_name']}") print(f"Reward: {task['reward']} HYRA") print(f"Status: {task['status']}") print(f"Submitted: {task['submitted_at']}") print(f"Verified: {task['verified_at']}") print("---")// Get detailed task historyconst tasks = await client.getTaskHistory();tasks.forEach((task) => { console.log(`Task ID: ${task.taskId}`); console.log(`Model: ${task.modelName}`); console.log(`Reward: ${task.reward} HYRA`); console.log(`Status: ${task.status}`); console.log(`Submitted: ${task.submittedAt}`); console.log(`Verified: ${task.verifiedAt}`); console.log("---");});4. ZKP Proof Monitoring
Section titled “4. ZKP Proof Monitoring”Get ZKP Status
Section titled “Get ZKP Status”# Check ZKP proof statuszkp_status = client.get_zkp_status()print(f"Proofs Generated: {zkp_status['proofs_generated']}")print(f"Proofs Verified: {zkp_status['proofs_verified']}")print(f"Pending Verification: {zkp_status['pending_verification']}")print(f"Failed Proofs: {zkp_status['failed_proofs']}")// Check ZKP proof statusconst zkpStatus = await client.getZKPStatus();console.log(`Proofs Generated: ${zkpStatus.proofsGenerated}`);console.log(`Proofs Verified: ${zkpStatus.proofsVerified}`);console.log(`Pending Verification: ${zkpStatus.pendingVerification}`);console.log(`Failed Proofs: ${zkpStatus.failedProofs}`);Get Proof Details
Section titled “Get Proof Details”# Get detailed proof informationproofs = client.get_proof_details()for proof in proofs: print(f"Task ID: {proof['task_id']}") print(f"Proof Hash: {proof['proof_hash']}") print(f"Status: {proof['status']}") print(f"Generated At: {proof['generated_at']}") print(f"Verified At: {proof['verified_at']}") print("---")// Get detailed proof informationconst proofs = await client.getProofDetails();proofs.forEach((proof) => { console.log(`Task ID: ${proof.taskId}`); console.log(`Proof Hash: ${proof.proofHash}`); console.log(`Status: ${proof.status}`); console.log(`Generated At: ${proof.generatedAt}`); console.log(`Verified At: ${proof.verifiedAt}`); console.log("---");});Advanced Monitoring Features
Section titled “Advanced Monitoring Features”1. Real-time Monitoring
Section titled “1. Real-time Monitoring”Set Up Real-time Updates
Section titled “Set Up Real-time Updates”import time
# Set up real-time monitoringdef monitor_rewards_realtime(): while True: try: # Check balance balance = client.get_balance() print(f"Current Balance: {balance['tokens']} HYRA")
# Check for new rewards new_rewards = client.get_new_rewards() if new_rewards: print(f"New rewards: {new_rewards}")
time.sleep(60) # Check every minute except KeyboardInterrupt: break
# Start monitoringmonitor_rewards_realtime()// Set up real-time monitoringasync function monitorRewardsRealtime() { while (true) { try { // Check balance const balance = await client.getBalance(); console.log(`Current Balance: ${balance.tokens} HYRA`);
// Check for new rewards const newRewards = await client.getNewRewards(); if (newRewards.length > 0) { console.log(`New rewards: ${newRewards}`); }
await new Promise((resolve) => setTimeout(resolve, 60000)); // Check every minute } catch (error) { console.log(`Monitoring error: ${error.message}`); await new Promise((resolve) => setTimeout(resolve, 60000)); } }}
// Start monitoringmonitorRewardsRealtime();2. Performance Analytics
Section titled “2. Performance Analytics”Get Performance Metrics
Section titled “Get Performance Metrics”# Get detailed performance analyticsanalytics = client.get_performance_analytics()print(f"Daily Average: {analytics['daily_avg']} HYRA")print(f"Weekly Total: {analytics['weekly_total']} HYRA")print(f"Monthly Total: {analytics['monthly_total']} HYRA")print(f"Best Day: {analytics['best_day']} HYRA")print(f"Success Rate: {analytics['success_rate']}%")// Get detailed performance analyticsconst analytics = await client.getPerformanceAnalytics();console.log(`Daily Average: ${analytics.dailyAvg} HYRA`);console.log(`Weekly Total: ${analytics.weeklyTotal} HYRA`);console.log(`Monthly Total: ${analytics.monthlyTotal} HYRA`);console.log(`Best Day: ${analytics.bestDay} HYRA`);console.log(`Success Rate: ${analytics.successRate}%`);Get Quality Metrics
Section titled “Get Quality Metrics”# Get quality-based reward metricsquality_metrics = client.get_quality_metrics()print(f"High Quality Tasks: {quality_metrics['high_quality']}")print(f"Quality Bonus Earned: {quality_metrics['quality_bonus']} HYRA")print(f"Average Quality Score: {quality_metrics['avg_quality_score']}")// Get quality-based reward metricsconst qualityMetrics = await client.getQualityMetrics();console.log(`High Quality Tasks: ${qualityMetrics.highQuality}`);console.log(`Quality Bonus Earned: ${qualityMetrics.qualityBonus} HYRA`);console.log(`Average Quality Score: ${qualityMetrics.avgQualityScore}`);3. Reward Management
Section titled “3. Reward Management”Withdraw Tokens
Section titled “Withdraw Tokens”# Withdraw your earned HYRA tokensdef withdraw_tokens(amount, address): try: tx_hash = client.withdraw_tokens(amount, address) print(f"Withdrawal successful: {tx_hash}") return tx_hash except Exception as e: print(f"Withdrawal failed: {e}") return None
# Withdraw 100 HYRA tokenswithdraw_tokens(100, "your_wallet_address")// Withdraw your earned HYRA tokensasync function withdrawTokens(amount, address) { try { const txHash = await client.withdrawTokens(amount, address); console.log(`Withdrawal successful: ${txHash}`); return txHash; } catch (error) { console.log(`Withdrawal failed: ${error.message}`); return null; }}
// Withdraw 100 HYRA tokensawait withdrawTokens(100, "your_wallet_address");Stake Tokens
Section titled “Stake Tokens”# Stake your HYRA tokens for additional rewardsdef stake_tokens(amount): try: tx_hash = client.stake_tokens(amount) print(f"Staking successful: {tx_hash}") return tx_hash except Exception as e: print(f"Staking failed: {e}") return None
# Stake 50 HYRA tokensstake_tokens(50)// Stake your HYRA tokens for additional rewardsasync function stakeTokens(amount) { try { const txHash = await client.stakeTokens(amount); console.log(`Staking successful: ${txHash}`); return txHash; } catch (error) { console.log(`Staking failed: ${error.message}`); return null; }}
// Stake 50 HYRA tokensawait stakeTokens(50);Monitoring Dashboard
Section titled “Monitoring Dashboard”1. Complete Monitoring Script
Section titled “1. Complete Monitoring Script”#!/usr/bin/env python3"""Complete monitoring script for Hyra Network rewards"""
from hyra_sdk import HyraClientimport timefrom datetime import datetime
def main(): # Initialize client client = HyraClient()
print("=== Hyra Network Rewards Monitor ===") print(f"Started at: {datetime.now()}") print()
# Get current status balance = client.get_balance() stats = client.get_task_statistics() zkp_status = client.get_zkp_status()
print("📊 Current Status:") print(f" Balance: {balance['tokens']} HYRA") print(f" Pending: {balance['pending']} HYRA") print(f" Total Earned: {balance['total_earned']} HYRA") print()
print("📈 Task Performance:") print(f" Total Tasks: {stats['total_tasks']}") print(f" Completed: {stats['completed']}") print(f" Success Rate: {stats['success_rate']}%") print(f" Average Reward: {stats['avg_reward']} HYRA") print()
print("🔐 ZKP Status:") print(f" Proofs Generated: {zkp_status['proofs_generated']}") print(f" Proofs Verified: {zkp_status['proofs_verified']}") print(f" Pending: {zkp_status['pending_verification']}") print()
# Get recent transactions recent_txs = client.get_transaction_history(days=1) if recent_txs: print("💰 Recent Transactions:") for tx in recent_txs[:5]: # Show last 5 print(f" {tx['type']}: {tx['amount']} HYRA at {tx['timestamp']}") print()
# Get pending transactions pending = client.get_pending_transactions() if pending: print("⏳ Pending Transactions:") for tx in pending: print(f" {tx['type']}: {tx['amount']} HYRA") print()
if __name__ == "__main__": main()#!/usr/bin/env node/** * Complete monitoring script for Hyra Network rewards */
const { HyraClient } = require("@hyra-network/sdk");
async function main() { // Initialize client const client = new HyraClient();
console.log("=== Hyra Network Rewards Monitor ==="); console.log(`Started at: ${new Date()}`); console.log();
// Get current status const balance = await client.getBalance(); const stats = await client.getTaskStatistics(); const zkpStatus = await client.getZKPStatus();
console.log("📊 Current Status:"); console.log(` Balance: ${balance.tokens} HYRA`); console.log(` Pending: ${balance.pending} HYRA`); console.log(` Total Earned: ${balance.totalEarned} HYRA`); console.log();
console.log("📈 Task Performance:"); console.log(` Total Tasks: ${stats.totalTasks}`); console.log(` Completed: ${stats.completed}`); console.log(` Success Rate: ${stats.successRate}%`); console.log(` Average Reward: ${stats.avgReward} HYRA`); console.log();
console.log("🔐 ZKP Status:"); console.log(` Proofs Generated: ${zkpStatus.proofsGenerated}`); console.log(` Proofs Verified: ${zkpStatus.proofsVerified}`); console.log(` Pending: ${zkpStatus.pendingVerification}`); console.log();
// Get recent transactions const recentTxs = await client.getTransactionHistory({ days: 1 }); if (recentTxs.length > 0) { console.log("💰 Recent Transactions:"); recentTxs.slice(0, 5).forEach((tx) => { console.log(` ${tx.type}: ${tx.amount} HYRA at ${tx.timestamp}`); }); console.log(); }
// Get pending transactions const pending = await client.getPendingTransactions(); if (pending.length > 0) { console.log("⏳ Pending Transactions:"); pending.forEach((tx) => { console.log(` ${tx.type}: ${tx.amount} HYRA`); }); console.log(); }}
main().catch(console.error);2. Automated Monitoring
Section titled “2. Automated Monitoring”# Set up automated monitoring with alertsdef setup_monitoring_alerts(): client = HyraClient()
# Set up monitoring thresholds MIN_BALANCE = 10 # Minimum balance alert TARGET_DAILY_EARNINGS = 50 # Target daily earnings
while True: try: # Check balance balance = client.get_balance() if balance['tokens'] < MIN_BALANCE: print(f"⚠️ Low balance alert: {balance['tokens']} HYRA")
# Check daily earnings daily_earnings = client.get_daily_earnings() if daily_earnings < TARGET_DAILY_EARNINGS: print(f"📉 Below target earnings: {daily_earnings} HYRA")
# Check for new rewards new_rewards = client.get_new_rewards() if new_rewards: print(f"🎉 New rewards received: {new_rewards}")
time.sleep(300) # Check every 5 minutes except Exception as e: print(f"Monitoring error: {e}") time.sleep(300)
# Start monitoringsetup_monitoring_alerts()// Set up automated monitoring with alertsasync function setupMonitoringAlerts() { const client = new HyraClient();
// Set up monitoring thresholds const MIN_BALANCE = 10; // Minimum balance alert const TARGET_DAILY_EARNINGS = 50; // Target daily earnings
while (true) { try { // Check balance const balance = await client.getBalance(); if (balance.tokens < MIN_BALANCE) { console.log(`⚠️ Low balance alert: ${balance.tokens} HYRA`); }
// Check daily earnings const dailyEarnings = await client.getDailyEarnings(); if (dailyEarnings < TARGET_DAILY_EARNINGS) { console.log(`📉 Below target earnings: ${dailyEarnings} HYRA`); }
// Check for new rewards const newRewards = await client.getNewRewards(); if (newRewards.length > 0) { console.log(`🎉 New rewards received: ${newRewards}`); }
await new Promise((resolve) => setTimeout(resolve, 300000)); // Check every 5 minutes } catch (error) { console.log(`Monitoring error: ${error.message}`); await new Promise((resolve) => setTimeout(resolve, 300000)); } }}
// Start monitoringsetupMonitoringAlerts();Implementation Notes
Section titled “Implementation Notes”For SDK Developers
Section titled “For SDK Developers”When implementing these monitoring features in your SDK, consider:
- Caching: Cache frequently accessed data to reduce API calls
- Rate Limiting: Implement rate limiting to avoid overwhelming the network
- Error Handling: Provide comprehensive error handling for network issues
- Real-time Updates: Use WebSocket connections for real-time updates
- Data Persistence: Store historical data locally for offline access
API Endpoints to Implement
Section titled “API Endpoints to Implement”# Core monitoring methods to implementclass HyraClient: def get_balance(self) -> Dict[str, int]: """Get current HYRA token balance""" pass
def get_transaction_history(self, **filters) -> List[Dict]: """Get transaction history with optional filters""" pass
def get_task_statistics(self) -> Dict[str, Any]: """Get task performance statistics""" pass
def get_zkp_status(self) -> Dict[str, int]: """Get ZKP proof status""" pass
def get_performance_analytics(self) -> Dict[str, Any]: """Get detailed performance analytics""" pass
def withdraw_tokens(self, amount: int, address: str) -> str: """Withdraw HYRA tokens to specified address""" pass
def stake_tokens(self, amount: int) -> str: """Stake HYRA tokens for additional rewards""" pass// Core monitoring methods to implementclass HyraClient { async getBalance() { // Get current HYRA token balance }
async getTransactionHistory(filters = {}) { // Get transaction history with optional filters }
async getTaskStatistics() { // Get task performance statistics }
async getZKPStatus() { // Get ZKP proof status }
async getPerformanceAnalytics() { // Get detailed performance analytics }
async withdrawTokens(amount, address) { // Withdraw HYRA tokens to specified address }
async stakeTokens(amount) { // Stake HYRA tokens for additional rewards }}Best Practices
Section titled “Best Practices”1. Regular Monitoring
Section titled “1. Regular Monitoring”- Daily Checks: Monitor your balance and recent transactions daily
- Weekly Analysis: Review your performance metrics weekly
- Monthly Reports: Generate comprehensive monthly reports
2. Performance Optimization
Section titled “2. Performance Optimization”- Batch Requests: Group multiple API calls together
- Cache Data: Store frequently accessed data locally
- Error Recovery: Implement retry logic for failed requests
3. Security Considerations
Section titled “3. Security Considerations”- Private Key Safety: Never expose your private key in monitoring scripts
- Secure Storage: Store sensitive data securely
- Access Control: Limit access to monitoring systems
Troubleshooting
Section titled “Troubleshooting”Common Issues
Section titled “Common Issues”-
Balance Not Updating
- Check if transactions are still pending
- Verify ZKP proof verification status
- Wait for blockchain confirmation
-
Missing Transactions
- Check transaction filters
- Verify date ranges
- Ensure proper API authentication
-
Performance Issues
- Implement caching
- Use batch requests
- Optimize API calls
Getting Help
Section titled “Getting Help”- Documentation: Check the official documentation
- Community: Join the Hyra Discord community
- Support: Contact support for technical issues
Next Steps
Section titled “Next Steps”- Set Up Monitoring: Implement the monitoring scripts
- Track Performance: Monitor your task completion success rate
- Optimize Earnings: Use analytics to improve your performance
- Manage Rewards: Withdraw and stake your HYRA tokens
Ready to start monitoring your rewards? Check out the Python SDK or Node.js SDK documentation for implementation details.