Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface DfuseClient

The DfuseClient interface is the back-bone of the library. Based on the Facade pattern, this client is your single go to point for interacting with dfuse Stream API as well as the dfuse REST API.

The client contains only top-level methods enabling you to retrieve all the information you need for your next-gen blockchain project.

The dfuse Client takes care for you of:

  • Management of WebSocket connection (automatic connection/disconnection when needed).
  • Management of the API key (API token retrieval, freshness and persistence).
  • Abstract dfuse API into simple to use top-level methods.
  • Error handling wrapping error received via WebSocket and REST into easy to use error.
group

Interfaces

Hierarchy

  • DfuseClient

Implemented by

Index

Properties

endpoints

Returns the final resolved endpoints urls currenctly in used by the client to reach dfuse services.

This is useful when using Apollo Client passing it the computed url without effort.

 const wsLink = new WebSocketLink({
   uri: dfuseClient.endpoints.graphqlStreamUrl,
   ...,
 });

getTokenInfo

getTokenInfo: function

Call this method each time you need an API token. Th returned API token is always valid. The expiration and the refresh of the token is handled automatically when using this method.

returns

A Promise that will resolve to a valid ApiTokenInfo instance, or will reject if an error occurs retrieving the API token.

Type declaration

Methods

apiRequest

  • An helper method that can be used to perform a generic HTTP call using the library inner configured HttpClient.

    This can be used to reach other REST API found on the nodeos process for example, those that are not directly included in the library but are still accessible via our endpoint like a /v1/chain/get_info or /v1/chain/push_transaction.

    Type parameters

    • T

    Parameters

    • path: string

      (required) The HTTP path on the endpoint

    • method: string

      (required) The HTTP method to perform the request agaisnt

    • Optional params: HttpQueryParameters

      (defaults {}) The HTTP query parameters to append to the url, they will be url-encoded and included in the final remote url. Has no effect when empty or undefined.

    • Optional body: any

      (defaults undefined) The HTTP body to include in the request, assumed to be a JSON object that will be serialized to a string. Not included in the HTTP request when undefined.

    • Optional headers: HttpHeaders

      (defaults {}) The extra HTTP headers to include in the request. Those will be merged with default ones ({ Authorization: ... }) and they override them if same key are specified.

    Returns Promise<T>

    A Promise that will resolve to the response body if it passes. Will reject with a DfuseApiError if it fits the dfuse Error Format or a generic DfuseError is it's something not fitting our expected format (nodeos erorr format for example).

authIssue

fetchBlockIdByTime

  • GET /v0/block_id/by_time

    Fetches the block ID, block time and block number for the given timestamp.

    Parameters

    • time: string | Date

      The reference timestamp to query for. If it's a string, assumed to be in ISO8601 extended format, i.e. 2019-03-04T10:36:14.5Z. If it's a date, it's going to be turned into an ISO8601 extended format relative to UTC.

    • comparator: ComparisonOperator

      Comparison operator for the block time. Should be one of:

      • gt (Greater Than time)
      • gte (Greater Than or Equal to time)
      • lt (Lower Than time)
      • lte (Lower Than or Equal totime)
      • eq (Strictly equal to time)

    Returns Promise<BlockIdByTimeResponse>

    A promise resolving to a BlockIdByTimeResponse object if the request was correct, or rejects with a DfuseApiError when it failed (or a more DfuseError when an unexpected error occurs).

fetchTransaction

release

  • release(): void
  • Release any resources hold by this DfuseClient instance. Must be tolerant to being called multiple times.

    Once called, the instance is assumed unsuable and should never be invoked anymore.

    Returns void

searchTransactions

stateAbi

  • stateAbi(account: string, options?: undefined | object): Promise<StateAbiResponse>

stateAbiBinToJson

  • stateAbiBinToJson<T>(account: string, table: string, hexRows: string[], options?: undefined | object): Promise<StateAbiToJsonResponse<T>>
  • GET /v0/state/abi/bin_to_json

    Fetches the ABI for a given contract account, at any block height.

    see

    https://docs.dfuse.io/#rest-api-post-v0-state-abi-bin_to_json

    Type parameters

    • T

    Parameters

    • account: string

      Contract account targeted by the action.

    • table: string

      The name-encoded table name you want to retrieve. For example, user balances for tokens live in the accounts table. Refer to the contract's ABI for a list of available tables. This is contract dependent.

    • hexRows: string[]

      An array of hexadecimal rows to decode. Each row must be a valid hexadecimal string representation of the row to decode against the ABI.

    • Optional options: undefined | object

      (optional) Optional parameters

    Returns Promise<StateAbiToJsonResponse<T>>

stateKeyAccounts

statePermissionLinks

stateTable

  • stateTable<T>(account: string, scope: string, table: string, options?: undefined | object): Promise<StateResponse<T>>
  • GET /v0/state/table

    Fetches the state of any table, at any block height.

    see

    https://docs.dfuse.io/#rest-api-get-v0-state-table

    Type parameters

    • T

    Parameters

    • account: string

      Contract account targeted by the action.

    • scope: string

      The name-encoded scope of the table you are requesting. For example, user balances for tokens live in their account name's scope. This is contract dependent, so inspect the ABI for the contract you are interested in.

    • table: string

      The name-encoded table name you want to retrieve. For example, user balances for tokens live in the accounts table. Refer to the contract's ABI for a list of available tables. This is contract dependent.

    • Optional options: undefined | object

      (optional) Optional parameters

    Returns Promise<StateResponse<T>>

stateTableScopes

  • GET /v0/state/table_scopes

    Fetches a list of scopes, for a given table on a contract account, at any block height.

    see

    https://docs.dfuse.io/#rest-api-get-v0-state-table_scopes

    Parameters

    • account: string

      Contract account holding the requested table.

    • table: string

      The name-encoded table name you want to retrieve scopes from. Refer to the contract's ABI for a list of available tables. This is contract dependent.

    • Optional options: undefined | object

      (optional) Optional parameters

    Returns Promise<StateTableScopesResponse>

stateTablesForAccounts

  • stateTablesForAccounts<T>(accounts: string[], scope: string, table: string, options?: undefined | object): Promise<MultiStateResponse<T>>
  • GET /v0/state/tables/accounts

    Fetches a table for a given contract account for a group of scopes, at any block height.

    see

    https://docs.dfuse.io/#rest-api-get-v0-state-tables-accounts

    Type parameters

    • T

    Parameters

    • accounts: string[]

      An AccountName list a maximum of 1500 elements can be present in the list.

    • scope: string

      A Name list, a maximum of 1500 elements can be present in the list.

    • table: string

      The name-encoded table name you want to retrieve. For example, user balances for tokens live in the accounts table. Refer to the contract's ABI for a list of available tables. This is contract dependent.

    • Optional options: undefined | object

      (optional) Optional parameters

    Returns Promise<MultiStateResponse<T>>

stateTablesForScopes

  • stateTablesForScopes<T>(account: string, scopes: string[], table: string, options?: undefined | object): Promise<MultiStateResponse<T>>
  • GET /v0/state/tables/scopes

    Fetches a table for a given contract account for a group of scopes, at any block height.

    see

    https://docs.dfuse.io/#rest-api-get-v0-state-tables-scopes

    Type parameters

    • T

    Parameters

    • account: string

      Contract account targeted by the action.

    • scopes: string[]
    • table: string

      The name-encoded table name you want to retrieve. For example, user balances for tokens live in the accounts table. Refer to the contract's ABI for a list of available tables. This is contract dependent.

    • Optional options: undefined | object

      (optional) Optional parameters

    Returns Promise<MultiStateResponse<T>>

streamActionTraces

streamHeadInfo

streamTableRows

streamTransaction

Generated using TypeDoc