HbarSuite Docs
  • Welcome to HbarSuite
  • HbarSuite Developer Documentation
    • HbarSuite Smart Engine Applications
      • @hsuite/cross-chain-exchange
      • @hsuite/dao
      • @hsuite/exchange
      • @hsuite/launchpad
      • @hsuite/multisig
      • @hsuite/nft-exchange
    • HSuite Libraries
      • @hsuite/api-key
      • @hsuite/auth-types
      • @hsuite/auth
      • @hsuite/client-types
      • @hsuite/client
      • @hsuite/dkg-types
      • @hsuite/hashgraph-types
      • @hsuite/health
      • @hsuite/helpers
      • @hsuite/ipfs
      • @hsuite/smart-config
      • @hsuite/smart-network-types
      • @hsuite/smart-transaction-types
      • @hsuite/smartnode-sdk
      • @hsuite/snapshots
      • @hsuite/subscriptions-types
      • @hsuite/subscriptions
      • @hsuite/throttler-types
      • @hsuite/throttler
      • @hsuite/users-types
      • @hsuite/users
      • @hsuite/validators-types
  • General Documentation
    • Tokenomics
      • Tokenomics v1
      • Tokenomics V2
    • Smart Apps and Interaction
      • Subscription-Based Model
      • Token-Gate Model
    • The Smart Node Network
      • security-layer
        • Security Layer Integration
        • Setting Up Secure Clusters
        • Generating and Sharing Keys Collaboratively
        • Protecting Secrets with Shamir's Method
        • Managing Cluster Membership
        • Handling Node Expulsion and Replacement
        • Automating Responses to Network Changes & Key Rotation
        • Ensuring Continuous Operation and Recovery
      • Understanding Validators in Our System
        • Type of Validators Explained
    • What is a Smart Node?
  • Restful APIs Documentation
Powered by GitBook
On this page
  • Description
  • Core Features
  • Installation
  • Usage
  • Basic Usage
  • Transaction Management
  • Account & Token Operations
  • Network Operations
  • Architecture
  • Documentation
  • API Documentation
  • Type Documentation
  • License
  1. HbarSuite Developer Documentation
  2. HSuite Libraries

@hsuite/hashgraph-types

Type definitions and interfaces for the HbarSuite Hedera Hashgraph integration.

Description

The @hsuite/hashgraph-types package provides a comprehensive set of TypeScript type definitions, interfaces, models, and namespaces for interacting with the Hedera Hashgraph network. It serves as the foundational type system for the HbarSuite ecosystem, ensuring type safety and providing clear contracts for Hedera network operations.

Core Features

  • 🏗️ Comprehensive Type System

    • Complete TypeScript definitions for all Hedera operations

    • Strongly typed interfaces for network interactions

    • Extensive model implementations with decorators

  • 🌐 Transaction Management

    • Detailed transaction type definitions

    • Transaction identity and authentication structures

    • Status tracking and result handling

  • 💰 Account & Token Operations

    • Account balance tracking

    • Token balance management (fungible and non-fungible)

    • Multi-token support

  • 🔐 Identity & Security

    • Private key management

    • DID (Decentralized Identifier) support

    • Multi-signature capabilities

  • 📡 Network Integration

    • Mirror node interaction types

    • Operator account definitions

    • Network configuration interfaces

  • 🛠️ Utility & Commons

    • Shared utility types

    • Common constants and helpers

    • RESTful API interfaces

Installation

npm install @hsuite/hashgraph-types

Usage

Basic Usage

import { IHashgraph, Hashgraph } from '@hsuite/hashgraph-types';

// Using interfaces
const operatorConfig: IHashgraph.IOperator = {
  accountId: "0.0.123456",
  privateKey: "302e020100300506032b657004220420..."
};

// Using models
const operator = new Hashgraph.Operator(operatorConfig);

Transaction Management

// Transaction details
const txDetails = new Hashgraph.TransactionDetails({
  transactionId: "[email protected]",
  status: "SUCCESS",
  consensusTimestamp: "2023-01-01T00:00:00.000Z"
});

// Transaction identity
const txIdentity = new Hashgraph.TransactionIdentity({
  signerPublicKey: "302a300506032b6570032100...",
  signature: "signed_transaction_bytes"
});

Account & Token Operations

// Account balance management
const accountBalance = new Hashgraph.AccountBalance({
  hbarBalance: 100,
  tokens: new Map([["0.0.123456", 1000]])
});

// Token balance tracking
const tokenBalance = new Hashgraph.TokenBalance({
  tokenId: "0.0.123456",
  balance: 1000,
  decimals: 8
});

Network Operations

// Mirror node configuration
const mirrorNode = new Hashgraph.MirrorNode({
  endpoint: "api.mirrornode.hedera.com",
  apiKey: "your-api-key"
});

// Network options
const options = new Hashgraph.Options({
  maxTransactionFee: 1000000,
  transactionValidDuration: 120
});

Architecture

The library is organized into several key namespaces:

  • IHashgraph: Root namespace for interfaces

  • Hashgraph: Root namespace for model implementations

  • Hashgraph.DID: DID-related functionality

  • Hashgraph.Restful: RESTful API interactions

  • Hashgraph.Commons: Shared utilities and constants

  • Hashgraph.Ledger: Ledger operations

Each namespace provides a clean and intuitive API for its specific domain while maintaining strong type safety.

Documentation

API Documentation

To generate and view the detailed API documentation:

yarn compodoc

To include coverage information:

yarn compodoc:coverage

Type Documentation

All types and interfaces are extensively documented with JSDoc comments, providing:

  • Detailed descriptions

  • Usage examples

  • Parameter descriptions

  • Return type information

License

This package is part of the HbarSuite ecosystem and is covered by its license terms.


Built with ❤️ by the HbarSuite Team Copyright © 2024 HbarSuite. All rights reserved.

Previous@hsuite/dkg-typesNext@hsuite/health

Last updated 3 months ago