Query Data
API
queryStake
async function queryStake(amount: bigint, options = { usd: false });
Stakes the specified amount of funds in order to perform queries.
amountis abiginttypeoptionsis an object with a single optional property,usd, which is a boolean indicating whether the amount is in USD.
query
async function query(
streamDefinition: StreamDefinition,
input: QueryInput,
onMessage?: MessageListener,
): Promise<LogStoreMessageStream>;
Queries a stream for historical data.
streamDefinitionis an object containing the stream ID and partition that should be queried.inputis an object that defines the query options. It can be of typeQueryInputand can have different forms likeQueryLast,QueryRange,QueryFrom.onMessageis an optional callback function for each message retrieved from the stream.
Returns a Promise that resolves to a LogStoreMessageStream object, providing an alternative way of iterating through the messages.
Example
// Staking some funds for the purpose of making a query
await logStoreClient.queryStake(STAKE_AMOUNT);
const queryResult = await logStoreClient.query(myStreamId, {
from: {
timestamp: 1685272949531,
},
to: {
timestamp: 1685272962273,
},
});