This client enables obtaining statistical information from the subgraph.
Unlike other SDK clients, StatisticsClient does not require signer or provider to be provided. We just need to create a client object using relevant network data.
constructor(network: NetworkData)
Installation
npm
npm install @human-protocol/sdk
yarn
yarn install @human-protocol/sdk
Code example
import { StatisticsClient, ChainId, NETWORKS } from '@human-protocol/sdk';
const statisticsClient = new StatisticsClient(NETWORKS[ChainId.POLYGON_AMOY]);
This function returns the statistical data of escrows.
Input parameters
interface IStatisticsFilter {
from?: Date;
to?: Date;
first?: number; // (Optional) Number of transactions per page. Default is 10.
skip?: number; // (Optional) Number of transactions to skip. Default is 0.
orderDirection?: OrderDirection; // (Optional) Order of the results. Default is ASC.
}
This function returns the statistical data of HMToken day by day.
Input parameters
interface IStatisticsFilter {
from?: Date;
to?: Date;
first?: number; // (Optional) Number of transactions per page. Default is 10.
skip?: number; // (Optional) Number of transactions to skip. Default is 0.
orderDirection?: OrderDirection; // (Optional) Order of the results. Default is ASC.
}
This function returns the statistical data of payments.
Input parameters
interface IStatisticsFilter {
from?: Date;
to?: Date;
first?: number; // (Optional) Number of transactions per page. Default is 10.
skip?: number; // (Optional) Number of transactions to skip. Default is 0.
orderDirection?: OrderDirection; // (Optional) Order of the results. Default is ASC.
}
type DailyPaymentData = {
timestamp: Date;
totalAmountPaid: BigNumber;
totalCount: number;
averageAmountPerWorker: BigNumber;
};
type PaymentStatistics = {
dailyPaymentsData: DailyPaymentData[];
};
This function returns the statistical data of workers.
Input parameters
interface IStatisticsFilter {
from?: Date;
to?: Date;
first?: number; // (Optional) Number of transactions per page. Default is 10.
skip?: number; // (Optional) Number of transactions to skip. Default is 0.
orderDirection?: OrderDirection; // (Optional) Order of the results. Default is ASC.
}
type DailyWorkerData = {
timestamp: Date;
activeWorkers: number;
};
type WorkerStatistics = {
dailyWorkersData: DailyWorkerData[];
};