Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ChainService

Generic Chain Service class.

This class can be used to call the chain api directly, in case a function is not supported yet by SignumJS. Usually, you won't need to do it.

Hierarchy

  • ChainService

Index

Constructors

Properties

Methods

Constructors

constructor

Properties

settings

Methods

query

  • query<T>(method: string, args?: any, options?: any | AxiosRequestConfig): Promise<T>
  • Requests a query to the configured chain node

    throws

    HttpError in case of failure

    Type parameters

    • T

    Parameters

    • method: string
    • Default value args: any = {}

      A JSON object which will be mapped to url params

    • Optional options: any | AxiosRequestConfig

      The optional request configuration for the passed Http client

    Returns Promise<T>

    The response data of success

selectBestHost

  • selectBestHost(reconfigure?: boolean, checkMethod?: string): Promise<string>
  • Automatically selects the best host, according to its response time, i.e. the fastest node host will be returned (and set as nodeHost internally)

    throws

    Error If reliableNodeHosts is empty, or if all requests to the reliableNodeHosts fail

    Parameters

    • Default value reconfigure: boolean = false

      An optional flag to set automatic reconfiguration. Default is false Attention: Reconfiguration works only, if you use the default http client. Otherwise, you need to reconfigure manually!

    • Default value checkMethod: string = "getBlockchainStatus"

      The optional API method to be called. This applies only for GET methods. Default is getBlockchainStatus

    Returns Promise<string>

send

  • send<T>(method: string, args?: object, body?: object, options?: any | AxiosRequestConfig): Promise<T>
  • Send data to chain node

    throws

    HttpError in case of failure

    Type parameters

    • T

    Parameters

    • method: string

      The method according https://www.burstcoin.community/burst-api/. Note that there are only a few POST methods

    • Default value args: object = {}

      A JSON object which will be mapped to url params

    • Optional body: object

      An object with key value pairs to submit as post body

    • Optional options: any | AxiosRequestConfig

      The optional request configuration for the passed Http client

    Returns Promise<T>

    The response data of success

toApiEndpoint

  • toApiEndpoint(method: string, data?: object): string