A developer-friendly SDK for interacting with the Proof-of-Workout (PoWk) protocol.
The hubx-sdk allows external applications to easily integrate with the Proof-of-Workout protocol. It provides a simple interface for verifying physical activity data, calculating activity scores, and retrieving proof certificates anchored to the Solana blockchain.
Install the SDK using npm:
npm install hubx-sdkTo use the SDK, initialize the PoWkClient with the base URL of the Proof-of-Workout API.
const PoWkClient = require('hubx-sdk');
// Initialize the client
const client = new PoWkClient('https://api.fastfithub.com');
// Define workout data
const workoutData = {
workoutId: 'unique-workout-id',
duration: 45, // in minutes
heartRate: 135, // in bpm
distance: 8, // in km
movement_flag: true // movement detected
};
// Verify the workout
client.verifyWorkout(workoutData)
.then(result => {
console.log('Verified:', result.verified);
console.log('Activity Score:', result.activityScore);
console.log('Proof Hash:', result.proofHash);
console.log('Solana Transaction:', result.solanaTx);
console.log('Rewards:', result.rewards);
})
.catch(error => {
console.error('Error:', error.message);
});baseUrl: The base URL of the Proof-of-Workout API (default:http://localhost:3000).
Verifies a workout activity and returns the verification result, activity score, proof hash, and rewards.
workoutData: An object containing the workout data.duration: Duration of the workout in minutes (number).heartRate: Average heart rate during the workout in bpm (number).distance: Distance covered during the workout in km (number).movement_flag: Flag indicating if movement was detected (boolean).workoutId: (Optional) A unique identifier for the workout (string).
Returns a promise that resolves to an object with the following properties:
verified: Boolean indicating if the workout was verified.activityScore: The calculated activity score (number).proofHash: The deterministic SHA256 hash of the workout data (string).rewards: An object containing the calculated rewards for HUBX, BTC, and DOGE.solanaTx: The Solana transaction signature if anchored (string).
Retrieves a stored Proof Certificate by its unique workout ID.
workoutId: The unique identifier of the workout (string).
Returns a promise that resolves to the stored Proof Certificate object.
Check the examples/ directory for more detailed usage examples.
node examples/verifyWorkout.jsISC