This function returns all transaction details based on the provided filter.
This uses Subgraph
Input parameters
interface ITransactionsFilter {
networks: ChainId[]; // List of chain IDs to query.
fromAddress?: string; // (Optional) The address from which transactions are sent.
toAddress?: string; // (Optional) The address to which transactions are sent.
startDate?: Date; // (Optional) The start date to filter transactions (inclusive).
endDate?: Date; // (Optional) The end date to filter transactions (inclusive).
startBlock?: number; // (Optional) The start block number to filter transactions (inclusive).
endBlock?: number; // (Optional) The end block number to filter transactions (inclusive).
}
type ITransaction = {
block: number;
txHash: string;
from: string;
to: string;
timestamp: number;
value: string;
method: string;
};
Parameters
• filter: ITransactionsFilter
Filter for the transactions.
Returns
Promise<ITransaction[]>
Returns an array with all the transaction details.
Code example
import { TransactionUtils, ChainId } from '@human-protocol/sdk';
const filter: ITransactionsFilter = {
networks: [ChainId.POLYGON],
startDate: new Date('2022-01-01'),
endDate: new Date('2022-12-31')
};
const transactions = await TransactionUtils.getTransactions(filter);