triangle-exclamation
NOTE: this is still a draft, so it's subject to changes. This alert will be removed as soon as final version will be available

πŸ”§@hsuite/helpers - Utility Library

πŸ› οΈ Comprehensive utility library for Hedera Hashgraph development and market data integration

Essential helper functions for offline transaction handling, cryptocurrency price fetching via CoinGecko API, and enhanced logging capabilities within the Smart Node ecosystem.


Table of Contents


Quick Start

Installation

npm install @hsuite/helpers

Basic Usage


Architecture

Core Utilities

πŸ“Š Market Data Integration

  • CoingeckoHelper - CoinGecko API integration for cryptocurrency market data

  • Enhanced Error Handling - Robust data formatting and error management

  • Rate Limiting - Built-in API rate limiting and retry logic

πŸ“ Enhanced Logging

  • LoggerHelper - Advanced logging with global and instance-level control

  • Flexible Control - Enable/disable logging at global or service level

  • NestJS Integration - Extends NestJS Logger with enhanced functionality

⚑ Offline Transactions

  • HashgraphOfflineTransactionHelper - Hedera transaction utilities for offline workflows

  • Node Discovery - Automatic network node discovery and selection

  • Multi-Service Integration - Works with ClientService and NetworkService

Module Structure


API Reference

CoingeckoHelper

Constructor: new CoingeckoHelper(httpService: HttpService)

Methods

fetchTokenMarkets(coinId: string): Promise<TokenMarketData>

  • Retrieves comprehensive market data for a specific cryptocurrency

  • Parameters: coinId - CoinGecko coin identifier (e.g., 'bitcoin', 'hedera-hashgraph')

  • Returns: Formatted object with price, volume, supply, and metadata

  • Throws: Error if API request fails or invalid response

LoggerHelper

Constructor: new LoggerHelper(context: string)

Static Methods

setGlobalLoggingEnabled(enabled: boolean): void

  • Controls logging globally across all LoggerHelper instances

  • Parameters: enabled - Whether to enable global logging

Instance Methods

setLoggingEnabled(enabled: boolean): void

  • Controls logging for specific instance

  • Parameters: enabled - Whether to enable instance logging

Standard Logging Methods:

  • log(message: string, ...optionalParams: any[]): void

  • error(message: string, trace?: string, ...optionalParams: any[]): void

  • warn(message: string, ...optionalParams: any[]): void

  • debug(message: string, ...optionalParams: any[]): void

  • verbose(message: string, ...optionalParams: any[]): void

HashgraphOfflineTransactionHelper

Constructor: new HashgraphOfflineTransactionHelper(configService, clientService, networkService)

Methods

getHederaNodes(): Promise<AccountId[]>

  • Fetches all available Hedera network nodes

  • Returns: Array of AccountId objects representing network nodes

  • Throws: Error if network discovery fails

getRandomHederaNode(): Promise<AccountId>

  • Returns a randomly selected Hedera network node

  • Returns: Single AccountId for load balancing

  • Throws: Error if no nodes available


Guides

Market Data Integration Guide

Learn how to integrate CoinGecko API for real-time cryptocurrency market data. Set up token price monitoring, market cap tracking, and historical data analysis for your applications.

Enhanced Logging Guide

Set up advanced logging with global and instance-level control. Configure logging levels, structured logging patterns, and debug controls for production environments.

Offline Transaction Guide

Handle Hedera Hashgraph transactions for offline workflows and node management. Implement transaction queuing, node selection, and load balancing strategies.


Examples

CoinGecko Market Data Integration

Enhanced Logging Patterns

Offline Transaction Management


Integration

Required Dependencies

Environment Variables

Module Integration


πŸ’‘ Best Practices:

  • Use LoggerHelper for consistent logging across your application

  • Cache CoinGecko API responses to avoid rate limiting

  • Handle offline transaction errors gracefully with proper retry logic

⚠️ Rate Limits: CoinGecko API has rate limits. Consider implementing caching for production use.

Built with ❀️ by the HSuite Team Copyright © 2025 HSuite. All rights reserved.

Last updated