Options
All
  • Public
  • Public/Protected
  • All
Menu
description

This class defines the implementation of the NetworkParameters requirements for connections to dHealth Network.

Please, be mindful when modifying the network parameters as you may thereby invalidate transactions that are created with this library. Use with caution.

example

Using the dHealthNetwork class

// creating dHealth Network Parameters
const dHealth = new dHealthNetwork();



Other links

NetworkParameters

since

v0.3.0

Hierarchy

  • dHealthNetwork

Implements

Index

Constructors

  • new dHealthNetwork(parameters?: { currencyMosaicId?: string; epochAdjustment?: number; generationHash?: string; networkType?: number }): dHealthNetwork
  • Constructs an instance of network parameters to connect to dHealth Network.

    access

    public

    Parameters

    • parameters: { currencyMosaicId?: string; epochAdjustment?: number; generationHash?: string; networkType?: number } = ...

      (Optional) The network connection parameters (defaults to dHealth Network).

      • Optional currencyMosaicId?: string
      • Optional epochAdjustment?: number
      • Optional generationHash?: string
      • Optional networkType?: number

    Returns dHealthNetwork

Properties

currencyMosaicId: string

Contains a mosaic identifier in hexadecimal format. This is the identifier of the asset used to pay for fees on dHealth Network.

You should only ever change the default asset identifier when you aim to connect to a different network than dHealth Network.

Please, be mindful when modifying the currencyMosaicId value as you may thereby invalidate transactions that are created with this library. Use with caution.

access

public

readonly
example

1616978397

var

{NetworkType | number}

epochAdjustment: number

Contains an the UTC timestamp in seconds which is used as a security prevent time-attacks on dHealth Network.

You should only ever change the default epoch adjustment when you aim to connect to a different network than dHealth Network.

Please, be mindful when modifying the epochAdjustment value as you may thereby invalidate transactions that are created with this library. Use with caution.

access

public

readonly
example

1616978397

var

{NetworkType | number}

generationHash: string

Contains the identifier of the blockchain network and is used as a security to prevent transaction replays. When creating transactions, this identifier is attached so that after signing the transaction, the transaction can only be broadcast using dHealth Network Nodes.

You should only ever change the default identifier when you aim to connect to a different network than dHealth Network.

Please, be mindful when modifying the generationHash value as you may thereby invalidate transactions that are created with this library. Use with caution.

access

public

readonly
example

"ED5761EA890A096C50D3F50B7C2F0CCB4B84AFC9EA870F381E84DDE36D04EF16"

var

{string}

networkType: number

Contains the type of network that is used to broadcast transactions. Typically, this can contain either of 104 for a MAINNET network, or 152 for a TESTNET.

You should only ever change the default network type when you aim to connect to a different network than dHealth Network.

Please, be mindful when modifying the networkType value as you may thereby invalidate transactions that are created with this library. Use with caution.

access

public

readonly
example

104

var

{NetworkType | number}

Methods

  • getDeadline(unit?: number, type?: ChronoUnit): Deadline
  • This method should return a Deadline instance as defined in @dhealth/sdk. The transaction deadline consists of the UTC timestamp at which the transaction shall expire in case it is not yet confirmed in a block.

    Deadlines can be created that are longer than the default that is used 2 hours. Also, you can use the ChronoUnit enumeration values to change the type of unit for defining deadlines, i.e. change to 2 minutes.

    Note that transactions that are not yet confirmed in a block before the deadline expires, effectively expire and have to be re-broadcast with an updated deadline and signature.

    Details about ChronoUnit can be found in the documentation of the @js-joda/core package.

    access

    public

    Parameters

    • unit: number = 2

      (Optional) The number of hours/minutes/seconds to set as a deadline, defaults to 2.

    • type: ChronoUnit = ChronoUnit.HOURS

      (Optional) The type of unit to use, defaults to ChronoUnit.HOURS.

    Returns Deadline

    A UTC timestamp represented as an object of Deadline.

  • getMaxFee(amount?: number): UInt64
  • This method should return the maximum fee that can be paid for a transaction to be included in a block. This amount is represented using the UInt64 class as defined in @dhealth/sdk and is protected for number overflows.

    access

    public

    Parameters

    • amount: number = 0

      The amount of assets to be attached as a fee for the node operator.

    Returns UInt64

    A number of assets ("amount") that is attached to a transfer transaction as the fee for the node operator.

  • getMosaic(amount?: number): Mosaic[]
  • This method should return an array of Mosaic instances as defined in @dhealth/sdk. The transaction assets consists of a set of assets that are attached to a transaction on dHealth Network.

    access

    public

    Parameters

    • amount: number = 0

      The amount of assets to be attached ("how many").

    Returns Mosaic[]

    An array of assets and amounts thereof that are attached to a transfer transaction.

  • getNetworkType(): NetworkType
  • This method should return a NetworkType instance as defined in @dhealth/sdk. Typically, this can contain either of 104 for a MAINNET network, or 152 for a TESTNET.

    access

    public

    Returns NetworkType

    A number represented as one of the values in the enumeration NetworkType.

  • getPublicAccount(publicKey: string, networkType?: NetworkType): PublicAccount
  • This method should return a PublicAccount instance as defined in @dhealth/sdk and uses a public key, as well as a network type to be able to create the correct account.

    The PublicAccount class of @dhealth/sdk permits to refer to pairs of public key and address which belong together and can both be used to identify accounts.

    As it is not possible to tell a public key from an address, other than by executing connected network requests, we use public keys so that we are always able to perform both tasks: identifying an account (by an address) and verifying transactions (with a public key).

    access

    public

    Parameters

    • publicKey: string

      The account's public key. This is a string of 64 characters in hexadecimal notation.

    • networkType: NetworkType = NetworkType.MAIN_NET

      This can contain either of 104 for a MAINNET network, or 152 for a TESTNET.

    Returns PublicAccount

    A public account information from dHealth Network. This consists of a pair of public key and address.

Generated using TypeDoc