Skip to main content

Data Module

This module is to construct the data in term of dataclass to make sure that all the input and output follow this data schema.

Although there are Protobuf classes, some types are not exists. Therefore, additional types of data will be declared here.

note

Note that base and quote is the first and the second price symbols respectively e.g. BTC/USD price rate has a base of BTC and a quote of USD.

ReferenceDataUpdated

AttributeTypeDescription
baseintegerBase's resolve time
quoteintegerQuote's resolve time

ReferenceDataRequestID

AttributeTypeDescription
baseintegerBase's request ID
quoteintegerQuote's request ID

ReferenceData

AttributeTypeDescription
pairstringThe token pair e.g. "BTC/USD"
ratefloatPrice rate
updatedAtReferenceDataUpdatedPrice update time
requestIdReferenceDataRequestIDOracleRequest ID

Syntax

(method) Client.getReferenceData(pairs: string[], minCount: number, askCount: number): Promise<Data.ReferenceData[]>

Example

import { Client, Data } from "@bandprotocol/bandchain.js"

async function getReferenceData() {
const grpcEndpoint = ${GRPC_ENDPOINT}
const client = new Client(grpcEndpoint)
const data = await client.getReferenceData(["BTC/USD", "ETH/BTC"], 3, 4)
console.log(typeof data) // Promise<Data.ReferenceData[]>
}